No, you can't do that, but you can encrypt the file and prevent people from
accessing the code.
Another option is to use some tool to obfuscate it, so it's not so easily
If this is still not sufficient, then maybe using scripts in a PDF is not
the solution for you and you need a more secure medium, like a web-page.