And is is possible to do that from code?
Possible probably, but not by any prebuilt API that I know of. If you could sign code from code it would allow self modifying to stay signed. That would be a bit of a security issue.
Now VBA does allow for binary read/writes you could slap a monitor on your application and watch what happens when you sign code and replicate what it is doing. But I'd guess that would be pretty non-trivial.
You could of course kludge together using sendkeys... But don't.
Out of curiosity, what problem are you trying to solve?