If the Defending Pokemon retreats while the song for Imakuni?'s Doduo's "Harmonize" attack is being sung, does that prevent the damage?
No, since the damage does not take place until the song is finished, the opponent's Active Pokemon at the end of the song will receive the damage.
Source: Evolutions FAQ (2016-11-03), TPCi Rules Team (2016-11-03)

Relevant cards

Note: All applicable cards may not be listed below.
XY12_112