The remote in your pic looks like an old Apple remote that used IR (infra-red) light to communicate with a Mac or an AppleTV device. Look at the front end of it and there you'll see, I believe, a small dark rectangular lens through which the light signal passes.
The Mac, any Mac, has not had an IR receiver built into it for over a decade. So this won't work.
However, there are bluetooth remotes available that work with either a small bluetooth receiver dongle that plugs into a USB port, or maybe even a remote that pairs directly with the Mac. These are typically used for presentations but may also work with the Music app.
Do a search with google or on the Amazon website to find lots of examples.