People seem to come up with all manner of complicated setups with virtual machines or docker or whatever.
All you need is a separate limited user account on your computer. Multi-user Unix-y systems were designed for this kind of thing for decades.
My entire development environment is literally just "sudo".
The advantage of VMs is that you can nuke them and be done with it if you need to.
I use my personal laptop for $WORK and everything work related is done via the VM.
your kernel is not isolate and if you accidentally run the wrong command in sudo you will nuke your computer lol
or just have a linux vps and ssh in for $5 a month