I have finally reproduced the bug about “System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out ” error being raised when it should not be raised. It happens when there is a thrown and caught mixed DML Exception in the setup transaction inside a Queueable job, and a callout from queueable or batchable in the test transaction (but not in future method).
Code of dummy batchable class b can be located here: https://gist.github.com/bdovhan/76326745c347dde00717c0318e3bc15b
Code of Apex Test Class TRB reproducing the CalloutException bug referencing class b in one test method can be found here
In this class, there are three apex test methods. Methods testB and testQ, which make callout from Queueable or Batchable, fail, while method testF, which makes callout from Future method, doesn’t fail.
I have also created a repository which contains both apex classes and setup scripts to create a scratch org and push the script to the scratch org.
Currently working with Salesforce support to identify this as an issue and retrieve from them acknowledge of this issue.