Classical education included music as one of the liberal arts since the times of Plato's Academy, see quadrivium, so most physicists had musical background until the end of 19th century. But there also seems to be something of a general appeal music has for physicists that continues into recent times, see Gold, Is it the mystery, or the structure, or the discipline?
Some prominent examples:
Heisenberg: "Werner Heisenberg was born in Würzburg, Germany, on December 5, 1901, and from birth, he seemed destined to become a concert pianist. With help from his mother, Anna, Werner was reading sheet music by age 4 and conquering the masterworks on the family's piano by the time he was 15. But Heisenberg's musical aspirations were slowly sabotaged by the family's book collection. His father, Albert, was a professor of Greek at the University of Munich, and Werner took a liking to rummaging through his dad's bookshelves. Before long, the young Heisenberg decided he preferred Archimedes to Mozart, and science replaced music as his passion."
Einstein:"It’s little known that Einstein was an accomplished violinist, and even less known that had he not pursued science, he said he would have been a musician... He confessed to thinking about science in terms of images and intuitions, often drawn directly from his experiences as a musician, only later converting these into logic, words and mathematics.".
Helmholtz:"Palestrina's music clearly caught Helmholtz's imagination. In his volume On the Sensations of Tone, he repeated the latest findings on the composer's alleged Protestant influences; for the Prussian scientist, they explained the clarity of Palestrina's style. His analysis of the Stabat mater was directed at giving this clarity some foundation in the composer's acute awareness of distortions in harmony. The basic idea was that a composer's knowledge of how to combine sounds would come forward in the music itself, even if there were no explicit rules and even if the rules that had been formulated through instruction would not account for the physiological conditions of hearing."
Huygens: "Like his father, Christiaan was a more than competent musician. But whereas Constantijn enjoyed concert performances and the social possibilities that they opened up, Christiaan’s interest in music was more theoretical. In common with many thinkers of the 17th century, he had his own ideas of how music should sound, and he devised a division of the octave into 31 carefully spaced notes that he calculated would both make for a pleasing sound and facilitate matters important to performing musicians, such as transposition between keys. Unlike most, however, he went further and had built for him a special harpsichord that demonstrated this system.
Perhaps Christiaan’s feeling for music helped him to the realisation that, like sound, light too travels in a wavelike fashion."