I encountered a similar problem to what is being reported here but involving shell scripts. I've got a Big Sur system that has been working fine since early Big Sur developer betas running scripts that build and package our products. For reasons as yet unknown several of our scripts began failing to run with the past few days. No macOS update as applied. Specifically, attempts to run them in terminal result in errors like this ...
zsh: operation not permitted: _scriptNameRedacted_
While other scripts in the same folder execute without any problem. Attempts to edit the affected scripts by drag-n-dropping the files onto BBEdit or TextEdit or Xcode resulted in the OS alert dialog others have posted pictures of; the alert with "filename is damaged and can't be opened. You should move it to the Trash".
Strangely enough though, I can 'vi' to edit and also manually open with BBEdit, TextEdit, Xcode those script files using the 'File > Open' dialog in each respective app. I just can't drag-n-drop those files without getting the damaged file alert dialog. This would appear to indicate that the Finder and some level of the file OS considers these files damaged even though they are accessible by other means and appear to be intact and fully human readable. (these files are shell scripts). This points to quarantining.
Sure enough, looking at extended attributes on the affected files with 'xattr _filename_' in the terminal shows this attribute on the affected files ...
'com.apple.quarantine'
I removed that attribute on affected files with ...
> xattr -d com.apple.quarantine _filename_
... and these scripts are now executable from the terminal, and can again be drag-n-dropped onto an text editor without encountering the damaged file OS alert.
You can search for quarantined files in a given directory by doing this in Terminal ...
> cd _target_folder_
> xattr * | grep "com.apple.quarantine"
I don't yet know why or what triggered the quarantine on some of my script files while others files in the same folder and on the same volume were not put in quarantine. I do not know if the files were put in quarantine by the OS or virus software or something else. (examining virus log files show my script directories getting scanned but no files/folders getting flagged as suspect and/or put in quarantine).
CAUTION / WARNING
Please be extremely careful removing the quarantine attribute on files on your system. DO NOT do something like run a script that removes the quarantine flag on all files on a system. You would be circumventing some of the file level security measures of macOS and putting the integrity of your entire system at risk. In my specific case above, I'm was working with affected shell script files which are text in content and are easily confirmed as human readable and intact before I pulled the files out of quarantine to allow them to be opened/executable again. If this works for you, great, but be VERY CAREFUL removing the quarantine attribute on files. Do it manually and carefully inspect each file one by one.
For non-textual files here is alternate possible solution for you. For each affected file, in the terminal ...
> cat _filename_ > _filename_2_
Then open the '_filename_2_' with the necessary application. If the new file opens and appears intact, close the file, delete the original file and rename your new file with the old filename.
If you use the 'cat' method to repair a file and that file is an executable script, you will need to add the executable bit to the new file.
> chmod +w _filename_2_
Also note that the above repair attempts will only work on uncompressed non-document bundle files. If you can select a file, right click on it and you see 'Show Package Contents', then that file is a document bundle. If you have something like a 'myProject.xcodeproj' Xcode project document that won't open, you will have to manually repair that document bundle hiearchy. When it comes to putting a document bundle in quarantine I don't know if the OS flags the top level hierarchy of the bundle or each individual file in the document bundle.