Praise be to Allah.
If a child dies, we should not offer supplication asking for forgiveness for him, because no sin has been recorded against him, and forgiveness means concealment of the sin and not being brought to account for it.
As for mercy, there is nothing wrong with praying for mercy for the child, because all people, children and adults, need the mercy of Allah, may He be exalted.
The Sunnah is to offer supplication for the parents of the child.
See the answer to question no. 23301 .
There is no specific supplication narrated in the Sunnah to be offered for the parents of the child.
Ibn Qudamah (may Allah have mercy on him) said: If the deceased is a child, then instead of praying for forgiveness for him, we should say, “O Allah, make him reach Paradise ahead of his parents, and keep the reward for their loss with him for them; O Allah, make the balance of their good deeds weigh heavily by virtue of his loss, and make their reward great by virtue of his loss. O Allah, entrust him to the care of Ibrahim and join him with the righteous early generations of the believers, and protect him by Your mercy from the punishment of Hell. Grant him a home better than his home and a family better than his family…” and so on. Whatever supplication is offered, of what we have mentioned above or something similar, will be sufficient, and there is no specific supplication to be offered in this case."(Al-Mughni 2/182).
Al-Bahuti (may Allah have mercy on him) said: The reason why it is not Sunnah to pray for forgiveness for him is only because he is one who will intercede and is not one for whom intercession will be made, for the Pen has not recorded anything against him. Therefore it is better to offer supplication for his parents rather than for him, and the supplication we have mentioned above is appropriate in this situation. That is why it is recommended, like seeking forgiveness is recommended for an adult."(Kashshaf al-Qina‘ 2/115).
Shaykh Ibn ‘Uthaymin (may Allah have mercy on him) said: This is what the jurists said, and it is a good supplication, even though some of it is not narrated in the religious texts, but it is still a good supplication."( Liqa’ al-Bab al-Maftuh no.149).
And he (may Allah have mercy on him) said in ash-Sharh al-Kafi: that with regard to the words “and protect him by Your mercy from the punishment of Hell,” this confused the scholars and they said: How can we pray that Allah protect him from the punishment of Hell even though he will not be punished, because the Pen has been lifted from him [and there are no bad deeds in his record]? Some of them responded by saying that this refers to passing over by merely passing over it, and that includes children. But this answer is not proven. And if supplication is offered for the child’s parents, asking for mercy, steadfastness and reward for them, that is sufficient. End quote.
And Allah knows best.