I still haven't found a FOSS tool capable of signing pdfs (like docusign)
https://github.com/apache/pdfbox/blob/5b00807463279f1002e245...
Everything about PDF signatures is maddeningly complex.
As for libraries, you can use jsignpdf from the CLI, PyHanko for Python and probably even more that I don't know.
https://tsdgeos.blogspot.com/2022/03/okular-signature-suppor...
Or whether the signature is correct in all the small details, e.g. used algorithm, the included information.
And then it sometimes depends on the environment. For example, sometimes a digital signature is only considered valid if all the revocation information and all the certificates are included in the PDF.