If a person passes away while praying for the deceased, there is no specific dua (supplication) that needs to be said. However, it is recommended to seek forgiveness for the deceased and ask Allah for mercy and blessings upon them. Here is a simple dua that can be recited:
"O Allah, forgive [name of the deceased] and have mercy upon them. Grant them a place in Jannah (Paradise) and make their grave a place of comfort and light. O Allah, forgive their sins and accept their good deeds. Shower them with Your mercy and blessings. Ameen."
It is important to note that this is a general dua, and you can also make additional personal supplications for the deceased if you wish.