I've tried this myself and failed.
But I genuinely wonder, why you think this is illegal. I mean, do you think that Apple's T&C are laws? I can't think of anything else that activity would be in violation of.
Does this matter if you never signed a contract with Apple in the first place?
I failed at it too, but then some bright spark wrote this script that works like a charm. Bear in mind that the VM might be too slow for normal use.
They better figure this out and release some good VM support because I have very little interest in buying all of their stuff just so I can run my build.
I did get the VM to work eventually and have been experimenting with builds on that. The VM is slow so I'm starting to lose interest in doing any more grunt work for an extra 10% of revenue. Ah, who am I kidding. I'll do it because I'm just as greedy as they are.
In my experience developing cross platform open source software, doing builds isn't the biggest problem. The situations when you need to debug platform specific behaviour, integration with OS and verifying that your software is properly packaged for macOS is when you might want direct access to a real machine.
Basically apple forces everyone to only run MacOS on it's own hardware and it's own hardware is unsuitable for the usecase.
(And yes I know about the imgix mac pro cluster)