I think there is an ambiguity in this question, which perhaps other people will face as well: are you asking
- can you perform the “add link” option using AppleScript?
- can you use “add link” to link to AppleScript code displayed in a document?
If it’s #2, it would be useful to know what kind of document contains the AppleScript code you would like to link to. Is it, for example, a Markdown document containing a code block with AppleScript inside the code block?