In theory running a different version of the OS for testing. Be aware MacOS VMs cannot use iCloud services though, so if your goal is CI/CD in the VM none of your tests for iCloud will work.
Be aware MacOS VMs cannot use iCloud services though
I believe it needs extra work but can be done. It's a relatively common question in the Hackintosh community and they've figured it out.
It works. You just need a legit serial number from a device. I have used one from my mac and it worked.
Check out docker-osx. They have instructions on generating a serial number and getting it to work iirc