Mach-o header manipulations and OSX 12

I have binary generated by a non-xcode process which works. The way the binary is constructed means that the Mach-o headers are not correct for codesigning and I have a manual C program to correct the headers. This has worked fine for years but on OSX 12, after the header-manipulation runs, the signature generated by the compile of the binary is invalid and so the binary won't run any more (the usual "Killed" error). Codesigning also fails, presumably for the same reason.

So, the question is on OSX 12, after I have manually changed Mach-o headers, can I resign somehow to obtain a valid binary again for codesigning?

Mach-o header manipulations and OSX 12
 
 
Q