You can certainly offer up fasting and prayer for the soul of the deceased. Just tell the Lord you are offering it for the particular person’s soul.
Alternatively you can offer it for the Holy Souls in Purgatory in general, or for a specific group of Holy Souls (for example, your deceased ancestors, all deceased non-Catholics, all souls who have no one else to pray for them etc).
Your prayers can certainly be applied to any non-Catholics in Purgatory. It is likely that there are non-Catholics in Purgatory and that they need prayers. Certain Protestant sects do not pray for their dead, so we need to pray for them to help get them out of Purgatory more quickly or make their Purgatory experience a little easier.
There is no particular prayer that needs to be said. You can say any prayer you like, including Our Father, Hail Mary, the Rosary, the Divine Mercy chaplet, the “Eternal rest grant unto them, O Lord, and let perpetual light shine upon them…” Catholic prayer for the deceased, etc.
Google “Catholic prayer for the dead” and you’ll find lots of prewritten prayers.
You can also just talk to God in your own words.
You can have a Mass said for the deceased person’s soul, or for the Holy Souls in Purgatory in general. This usually involves a small donation. You can make arrangements for a Mass at your parish church or at an online site offering them such as Cnewa.org .
You can also go to Mass yourself and offer your Holy Communion up for the Holy Souls in Purgatory or for a particular soul. You can likewise pray for them at Adoration/ offer up your Adoration time for them.
You can also obtain indulgences and ask the Lord to apply them to the soul of the person or persons in purgatory.