Buying a secondhand Mac, or taking over an old work laptop? I’d want to know whether some company can still push settings to it. That’s what MDM enrollment does, and macOS has a built-in command to check it.
Run this:
profiles status -type enrollment
It shows the MDM enrollment status of the Mac, including whether it was enrolled through Apple’s automated device enrollment (the old DEP), and when the enrollment was approved by the user it adds “(User Approved)”. On a private Mac you want both answers to be no.
Then look at the configuration profiles. As root, with -all, list shows every profile installed on the system, not just the ones for your user:
sudo profiles list -all
Profiles can set things like a VPN, Wi-Fi, certificates or restrictions, so an unknown one on a used Mac is a reason to ask the seller questions. On a work Mac, of course, this is normal and you should leave the profiles in place.
Mind the rate limit if you dig deeper: profiles show -type enrollment asks Apple’s servers for the automated enrollment configuration, and that’s rate limited to 10 times every 23 hours. Since macOS 11 you can’t install configuration profiles with this tool any more; those go through System Settings.
Further reading: profiles man page
Going deeper: Guide: keep your Mac apps in a Brewfile, so a new MacBook is one command away