csrutil disable
Restart computer
In the terminal, type
sudo open /Applications/TextEdit.app /System/Library/LaunchDaemons/com.apple.ManagedClient.enroll.plist
change
<key>com.apple.ManagedClient.enroll</key>
<true/>
to
<key>com.apple.ManagedClient.enroll</key>
<false/>
So that the changes take effect
Had the same issue of wiping out my machine and got stucked on MDM when finishing the installation, but i fixed mine by reinstalling an older osx version "lion" then update to newer version up to "catalina" #2012MBP.