Following are notes I wrote on what I used to do under Lion and Mountain Lion to change the MAC address on a MBP (for testing server and security software). I used to use this quite often, but I haven't tested it recently so I don't know whether it still works under Monterey and on M1 Macs. (Reading the man page on "ifconfig", however, indicates that it should still work on Monterey and M1.)
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Mac OS X Lion: Change MAC address:
# The following command reads the current MAC address:
OLDMAC=`ifconfig en0 | grep ether | awk '{print $2}'`
echo " MAC address: $OLDMAC"
# The following command gets a random MAC address:
RNDMAC=`openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'`
echo " Random MAC address: $RNDMAC"
# The following command sets a random new MAC address:
sudo ifconfig en0 ether `echo $RNDMAC`
sudo ifconfig en0 down
sudo ifconfig en0 up
# The following command resets the original MAC address:
sudo ifconfig en0 ether `echo $OLDMAC`
sudo ifconfig en0 down
sudo ifconfig en0 up
# Alias:
alias changemac='sudo ifconfig en0 ether $(openssl rand -hex 6 | sed '\''s/\(..\)/\1:/g; s/.$//'\'')'
changemac
sudo ifconfig en0 down
sudo ifconfig en0 up
#--------------------------------------------------------------------------------
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$