In fact, the CertificatePinner.check() methods all throw if the certificate is invalid, rather than returning a boolean, in v3 and older versions.
A Frida script to disable SSL certificate pinning in a target application
For more information and detailed setup instructions, take a look at https://httptoolkit.tech/blog/frida-certificate-pinning/