Do I need the Developer Program to sign an app for my own use? I installed iTerm2 from MacPorts; since it was built from source, it wasn’t notarized. If I want to sign it for my own usage (not distributing any app), do I need to (pay $99 and) join the Developer Program? I have not joined the program, but apparently there is a local certificate with name “Apple Development:” followed by my Apple ID. Can I use that to sign? I tried
codesign --force --sign 'Apple Development: foo@example.com' /Applications/MacPorts/iTerm2.app

and saw error message:
/Applications/MacPorts/iTerm2.app: code object is not signed at all
In subcomponent: /Applications/MacPorts/iTerm2.app/Contents/XPCServices/pidinfo.xpc

background
The reason I want to sign iTerm2 is that unsigned version can’t run osascript to control another application. To verify:
osascript -e 'tell application &quot;Finder&quot; to display dialog &quot;hello!&quot;'

With unsigned iTerm2 I got authorization error (-1743). (Of course I intended to use OSA for more complicated automation.)
You do not need to join the $99 Developer program.
There are two cases:
Intel Mac: You do not need to sign the app.  And there may be an advantage to that as it then doesn't need to be checked for certificate revocation or notarisation.
M1 Mac: It must be signed, but you can do that with an ad-hoc signature with codesign -s - appname.app
Have a read of this from Howard Oakley.  It is focused on avoiding OCSP (certificate revocation checks), but has the detail you need which is not very much!
There are Apple documents too.  For example Open app from un identified developer.  Basically saying to Control-click and open.