It is hard to say a definitive no to "ever", but the facts are not there. First, as on can see from chronology in RadioSwiss database, Herschel wrote the bulk of his musical compositions in 1760-1769, before developing interest in astronomy. Second, we have plenty of first hand testimony about his life, much of it reviewed in Philomaths, Herschel, and the myth of the self-taught man by Winterburn. There are several autobiographies, including a "memorandum of life", and contemporary accounts by his sister Caroline, who lived with him, but none of them mention music inspired by astronomy. This is a particularly odd omission considering the traditional associations with the "music of the spheres" that go back to Pythagoreans. Moreover, we have positive evidence that Herschel was more "mathematical" and pragmatic than romantic in his composition of music, and gave it up with relief when offered a position of royal astronomer, see Sir William Herschel as a Composer by Duckles:
was nothing mystical or metaphysical in his approach to the art
of music. He was a practical musician of his time, and he lived
in a time when musicians were too much occupied with the problems
of survival to indulge in cosmic or sentimental views about
their role in society... One gets the impression from this concerto of a strong intellect
at work, a mind that takes willful control of the materials
and shapes them, even forces them, into line. He has a structural approach toward composition; he uses musical ideas as building
blocks and the joints by which they are connected are not always
smooth... It remains for the listener to decide whether or not the world
lost a great composer when it gained a great astronomer. Herschel
himself had no doubts in the matter."
Even the popular story about Haydn getting inspired to write his oratorio The Creation after conversing with Herschel at his observatory in 1792 (Herschel's own music is often characterized as "Haydnesque") turns out to be a fable. Herschel was away on the day of Haydn's visit and they never met, see Petzold, Haydn and Herschel in the Clair de Lune.
There is, on the other hand, plenty of evidence of the converse - that Herschel's experience with music led him to develop interest first in mathematics, and then in optics and astronomy. His evolution is documented in detail by Winterburn. The stimulus was Robert Smith's book Harmonics, or the Philosophy of Musical Sounds that inspired Herschel to write his own Treatise on Music (1764, unpublished), where it is cited for the "mathematics of harmonics", and "mathematical division of intervals". And the catalyst was Herschel's involvement with the Philomaths society that promoted new mathematics and natural philosophy from 1766 on.
What followed was reading Maclaurin's Treatise on Fluxions and Smith's also Compleat System of Opticks that included telescope designs. With the help of Caroline and brother Alexander, who joined him in Bath in 1772, Herschel started constructing his own telescopes. But by then he stopped composing, although kept performing to earn a living (he was an organist at the Octagon Chapel in Bath since 1767). In the late 1770s he was writing on natural history, electricity and, of course, astronomy, and regularly presenting his research to Bath Philosophical Society.
"William had learnt music through concentrated repetitive solitary practice from an early age and here, described in Smith, presented as an application of Locke's ideas, was that same practice applied to sight... By practising observing as he had practised music, William became an excellent observer. His instrument-making skills also improved as he practised and perfected the art of mirror making, experimenting with different alloy compositions and polishing techniques... By the end of 1779 William had successfully tested the quality of his telescopes and... began to report on observations made with his telescopes. Two of these papers—one on a star in Collo Ceti, the other on lunar mountains—were later read to the Royal Society... When he came to discover the planet Uranus in 1781, his involvement with the society meant he knew just how to word his announcement and whom to tell."
When Lalande informed Herschel about calculations performed on his new planet and inquired about his biography, the latter gave him a glossed version that he was "brought up to Music", but "my leisure hours were generally devoted to mathematics and other studies". In 1782 he was offered a position as Astronomer Royal for King George III, as well as funds for building bigger telescopes, and left his musical posts in Bath. His transition from music to astronomy was complete.