Notes: From Zeno Popovici with edits & tested on a M1 macbook with Ventura (macOS 13).
In macOS you can check the MDM status with the following command in a Terminal:
profiles status -type enrollment
Non-removable MDM profiles cannot officially removed without doing a full system wipe