(Edited: the comments indicates this is no longer possible)
(Edited: the comments indicates this is no longer possible)
I did it a couple years ago on a last generation Intel-based MBP to troubleshoot a problem caused by a particular piece of software installed by our IT team who, for various reasons, were unable to assist.
Caveat: I don't know if this is possible anymore on Apple silicon-based Macs because they apparently "require an internet connection to get firmware and other information specific to the Mac model."[^1]
The trick was to:
1. Use a freshly created bootable installer volume.[^1] (If previously setup, management software will often inject itself into the existing Recovery volume).
2. Prevent it from connecting to the internet, including any previously connected WiFi network it might remember.
3. Get it through the installation and initial user creation without being able to connect to the internet.
After that, it didn't pester me until the next reinstall.
On an Apple Silicon Mac you may have to install Monterey first, which doesn't require internet, do some incantantions, and then you can upgrade to Sonoma with no issue, and DEP/MDM bypassed.
>>>>Easily skipped .....by blocking connection to enrollment server
Probably not the avg user or engineer (though giving engineers admin account on their local OS is common). But that's hard to predict because usually you'd want to enroll, so I don't often see people trying to avoid it. Usually it's because of a bug. In my experience if the MDM process is buggy then it's more likely to be bypassable.
Setting a firmware password and blocking boot to external drives makes it harder, but a lot of orgs don't do it.
Last instructions I saw and tested said "install Monterey with no internet connection, open terminal, sudo nano /etc/hosts, add these three entries, save, close, upgrade to Sonoma".
That fully disabled MDM/DEP on an M2 MBP. Not sure if it would periodically ping after install/upgrade, but is about as clean as it gets, and for now survives OS upgrades.
During OS install the enrollment will just happen; the user's acceptance is not required.