I presume that you mean when a Catholic has passed away.
For a Catholic, I offer prayers for the soul of the departed, as well as for the family who have been left behind.
For a non-Catholic, I will say that I am sorry for their loss and offer prayers for the family left behind, but not for the repose of the individual's soul.
While it is possible that some soul may have received the grace of an unknown deathbed conversion, to offer prayers for the repose of that soul could create the scandal of promoting the notion that there can be salvation outside the Church. Privately, I may offer some prayers that the person should be converted in the past, since it's certain that God is not bound by time and could indeed hear prayers from (what to us is) the "future" if He willed to. Classic example is how Our Blessed Mother was redeemed by Our Lord "prior" in time to Our Lord's Passion.
It's a little more tricky with ѕυιcιdєs and public sinners who had been Catholics, to balance offering sympathy, not absolutely assuming that the individual has been lost, since if God saved them somehow, they could certainly use the prayers, without at the same time implying that there's "good hope" for the salvation of ѕυιcιdєs and (seemingly) unreprentant public sinners. I've mentioned the story of serving funerals (when I was between 10-14) at the Novus Ordo. I was actually their go-to server at the parish school, so I was regularly pulled out of class to serve funerals that took place during the weekdays. In any case, there were occasionally funerals for ѕυιcιdєs, and the priest generally gave a sermon along the lines of how the person is in a better place now and relieved of the suffering that was so unbearable as to result in the ѕυιcιdє. If I didn't know any better, and had I some day encountered such a situation of extreme distress, that sermon would have been almost an encouragement to commit ѕυιcιdє, to escape the suffering and go to that "better place".