Considering that it's assur to think about Torah in the bathroom, is it permissible to think about a song whose lyrics are Torah? If not, what about an earworm that you just can't get rid of?
Rav Shlomo Zalman Auerbach זצ״ל quoted in הליכות שלמה (הלכות תפילה פרק עשרים סימן יא אות כא) ruled that there is a distinction between recital of pesukim-versus in praise and song-דרך שבח וזמרה and studying-דרך לימוד.
Singing pesukim does not constitute as limmud HaTorah, thus, Rav Shlomo Zalman Auerbach זצ״ל rules that if ones mother, wife who is not in niddah, daughter or sister even if she is married is singing Shabbos Zmiros or Eishes Chayil, which includes pesukim, it is permitted to hear them sing while you are singing.
However Rav Shlomo Zalman Auerbach זצ״ל rules that this distinction does not apply to ״מקומות המטונפים״ Filthy places.
See also the Sefer ואשי ישראל הערה צ״ו וק״ג
According to this it would prohibit even the thinking of songs that include pesukim in the bathroom as it is classified as a filthy place
The implications of the ruling however though are dependent on whether we in actuality classify bathrooms today as filthy places:
What about todays Bathrooms?
There is a major dispute among the poskim whether or not today's modern day bathrooms are considered to be like the bathrooms of earlier times. Ealier style toilets did not retain waste materials and were known as "parsoy."(Gemorah Berochos 26a, Rashi d'parsoy," Shulchan Aruch 83:4.) In present day toilets the waste remains until it is flushed away. Nonetheless, many poskim say that our bathrooms are considered the same as the olden style bathrooms and one can be lenient in regard to the halachos that apply.(Minchas Yitzchok 1:60, Yechaveh Da'as 3:1, Ohr L'tyzion 1:1, 2:1:9, Shearim Metzuyanim B'Halacha 1:2:6) However, most poskim argue.(Har Tzvi O.C. 1:50, Chazzon Ish O.C. 17:4, Igros Moshe E.H. 1:114,Halichos Shlomo Tefilla 20:24, Yabea Omer 3:2) Therefore, in case of necessity one can rely on the lenient view, but l'chatchilah our bathrooms do not have the status of the bathrooms of "parsoy."(Minchas Yitzchok 1:60)
[above paragraph copied from this answer]
Thus, if one classifies our modern day bathrooms as מקומות המטונפים - filthy places, then thinking of the songs would be prohibited. But if one does not classify the bathroom as a such, then it would be permitted.
(As an aside even according to the most lenient view obviously at the time that the person is defecating and the filth is present it would be prohibited)
Based on this distinction Rav Chaim Pinchos Sheinberg זצ״ל was quoted as to have permitted boys to listen to Jewish music in the bathroom and shower.
One may not draw any practical Halacha from this answer as per site guidelines, please consult your local orthodox Rabbi