URLConnection Certificate Pinning Possible?

Does anyone know if it’s possible to do certificate pinning with URLConnection?

I don’t just need to validate the certificate, I need to make sure it is mine and that an IT department hasn’t injected themself into the communication stream.

I need to do this on both macOS and Windows, and for this use case plugins are not an option. It would need to be in the framework or with declares.