In the Babylonian Talmud, Tractate Megillah, 10B, we find this:
And Rabbi Yochanan said: Why is it written in Ex. 14: “They did not come near to one another, this one to that one, for the whole night?” The Egyptian army and the Israelites, waiting to cross the Sea of Reeds, were separated by the Cloud of Glory, which kept the two camps separated overnight. The angels of the heavenly court requested permission to recite transcendent song. The Holy One, Who is Blessed, said to them: “The work of My hands is drowning in the sea, and you are reciting song?”
The words of God, "that The work of My hands is drowning in the sea, and you are reciting song?", have usually been interpreted as meaning even when your enemy falls, do not rejoice or, even in battle, observe the rules of humanity.
But already in the following lines of the Talmud, there is an exception:
Rabbi Elazar said: God does not rejoice, but others are permitted to rejoice. This is also shown in the text, for it is written “ken yasis“ and it is not written “ken yasus“. ”yasis” is the hif’il [active-causative] form, “yasus” is the kal [active-simple] form; the difference is that “yasus” could only mean “He (himself) rejoices,” whereas “yasis” can also mean “He causes others to rejoice,” which is the way that Rabbi Elazar understands the text.
And another example is quoted by a Rabbi Jill Jacobs here:
But the midrash grows more interesting within the context of another midrash, this one included in Eicha Rabbah, the major compilation of Midrashim on the book of Lamentations. According to this second midrash:
On three occasions, the angels wanted to sing praises before God, and God would not
permit them. What are these? The generation of the flood [in which only Noah and his family were saved]; the crossing of the Red Sea; and the destruction of the Temple in Jerusalem. . . God said, “These comforting words that you say to me are insults to me.” (Petichta 24 in Vilna edition)
However, the Vilna Gaon suggests a more radical interpretation. According to a new book, HaMaor HaGadol, p. 148, the Binat Yisachar published in 1924, p. 40 is quoted that the author heard in the name of the Vilna Gaon this version:
"the angels wanted to sing as a method of killing the Egyptians just as their voices were to cause the death of Sancheriv's soldiers (II King, 7:6) * but God said, no, it's all my work to be done with no agents, for "the work of my hands" who are in danger of drowning are not the Egyptians but the Israelites (Bnei Yisrael). And the punishment must fit the sin [middah k'neged middah] for just as the Egyptians are attempting to drown the Israelites, they themselves must be drowned and not killed through the vehicle of your song".
The reference to the death of Sanheriv's soldiers is somewhere else.
Here is the Talmudic section of Sanhedrin 95b:
Rab Judah said in Rab's name: The wicked Sennacherib advanced against them13 with a force consisting of forty-five thousand princes, each enthroned in a golden chariot and accompanied by his ladies and harlots, eighty thousand warriors in coat-of-mail, and sixty thousand swordsmen of the front line, the rest cavalrymen. A similar host attacked Abraham ,14 and a like force will accompany Gog and Magog.15...
...But is it not written, Then the angel of the Lord went forth, and smote in the camp of the Assyrians an hundred and fourscore and five thousand: and when they arose early in the mornings behold, they were all dead corpses?19...Rabina said: This may be also deduced, for it is written, And the Lord sent an angel, which cut off all the men of valour, and the leaders and the princes in the camp of the king of Assyria...
Wherewith did he [the angel] smite them? — ...R. Isaac the Smith said: He unsealed their ears for them, so that they heard the Hayyoth32 sing [praises to God] and they died, as it is written, at thine exaltation the people were scattered.33
13 The Israelites in the days of Hezekiah.
14 On the occasion of his pursuit of the four kings. (Gen. XIV).
15 V. p. 630, n. 6.
19 Isa. XXXVII, 36, proving that this was the size of the army.
32 [The celestial 'living creatures' mentioned in Ezekiel's mystic vision; v. Ezek. I and X.]
33 Isa. XXXIII, 3. The first half of the verse reads, At the noise of the tumult the people fled. 'Tumult' is taken to refer to the song of the Hayyoth in their 'exaltation' of the Lord.