Changing a document invalidates the signature. And in many cases (optionally signing locks the file). And, setting security changes the file. So this wouldn't be good.
Do your actions the other way round - being sure your security setings allow signing of course!
You need to encrypt file first (that's what happens when you apply restrictions) and sign second. Be sure to pay attention to the alert that comes up when you set restrictions. Other than Adobe PDF Viewers may not respect these restrictions.