Backport of [[https://github.com/bitcoin/bitcoin/pull/22089 | core#22089]].
Instead of the retry loop to get a fixed DER signature size, we could use the Schnorr signatures which are fixed size.
However the only test that uses the P2PK mode so far is the DER signature test, and using schnorr would invalidate the test.