There are number of sources on the internet that tell you how to do it. Here is a youtube video of one of them.
I have done it a few times here at home on my "new to me" machines.
But basically if you do a google search of "remove mdm profile from mac" you will find many resources avaiable to review.
Here are the notes that I have when I do ...
Assuming your hard drive is labeled "Macintosh HD", this is how you disable
the mdm popup:
Boot to Recovery Mode by holding command-R during restart and continue with
Main procedure
Main procedure
Open Utilities → Terminal and type
$ csrutil disable
$ reboot
Hold command-R during the reboot to enter Recovery Mode again
Enter Disk Utility, and mount the Macintosh HD volume (or whatever your
main volume is named). (It might already be mounted.)
Exit Disk Utility, open Utilities → Terminal, and type
$ cd "/Volumes/Macintosh HD/System/Library"
$ cd ../../etc
$ echo "0.0.0.0 iprofiles.apple.com" >> hosts
$ echo "0.0.0.0 mdmenrollment.apple.com" >> hosts
$ echo "0.0.0.0 deviceenrollment.apple.com" >> hosts
$ echo "0.0.0.0 gdmf.apple.com" >> hosts
$ csrutil enable
$ reboot
---------------------------------------------------------------
Then you also have to delete the existing MDM profile info from
/var/db/configurationprofiles/settings/
/var/db/configurationprofiles/store/
The files may be hidden so you won't see them unless you use "ls -a".
Remove the the files from /settings/ with: rm .* and remove the
files from /store/ with: rm *
csrutil enable
reboot
———
After all Is done, from terminal type
profiles status type -enrollment
It should say
Enrolled via DEP: No
MDM enrollment: No