This is a partial backport of electrum#5820
See also D4467
Note that Electrum ABC produces schnorr signatures for most transactions, so for most users this is not going to change much. It makes future backports a bit easier by adhering more closely to the Electrum code.
And I didn't backport the change in the pure python version of signing as this code is going to be dropped very soon.
Depends on D16684