I hate how MacOS would start Apple Music every time I accidentally tapped my earbuds. To disable it I used an even lower tech solution, which works on corp laptops that don't allow installing arbitrary software:
1. Open System Settings
2. Navigate to Screen Time -> App Limits -> Add Limit...
3. Select "Music" and set an "Every Day" limit of 0 minutes.