Apple's Messages app is not listed among the apps in Security settings for Screen Recording. This would be the normal place for most apps to disallow screen sharing, but the absence of Messages from the list seems to mean that there's no way to control this in the normal GUI.
How do I disallow screen sharing for Messages?