Override iTunes "media" keys (play, pause, etc) for Spotify?
The software Beardedspice provides a user-friendly approach to prioritizing Spotify for your media keys. It runs in the background and gives you a few simple settings in the Mac menu bar. It just works.

Download and installation
It can be downloaded and installed directly from the Beardedspice homepage, or by using e.g. Homebrew:
brew install --cask beardedspice

Notes

It is compatible with macOS Big Sur.
Ensure the application is given sufficient privileges in Security &amp; Privacy in the System Preferences.
Beardedspice supports controlling a vast amount of media players. Simply disable any unwanted players, while keeping Spotify enabled.
I am not affiliated with the developer(s), I am just a satisfied user.


Update 2021-01-16 - Use Beardedspice as the alternative app Mac Media Key Forwarder is no longer being updated
As there are reports of Mac Media Key Forwarder not working for some users, and the developer no longer updating the app, it is recommended to use Beardedspice.
Nevertheless, Mac Media Key Forwarder will still work fine for most people running on e.g. MacOS High Sierra, Mojave, Catalina, or Big Sur so it remains an alternative.

Download and installation
It can be downloaded and installed directly from GitHub, or by using e.g. Homebrew:
brew install --cask macmediakeyforwarder