It is fine to pray for anyone you wish. I frequently say a quick prayer for disabled people I see, or moms who are frazzled with crying kids, or jaywalkers who walk in front of my car. Just a “Please help that person, Lord” prayer.
I do not pray in a way anyone would hear, or tell the person I prayed for them unless we get into a conversation and they seem open to the idea of prayer.
It’s important to understand Catholic prayer is just an asking God to help the person. It does not have any effect like converting them to Catholicism or somehow making them a member of the church against their will. Also, be aware that some people react badly to prayers, so unless you are pretty sure the person is okay with them, be careful about mentioning you prayed for them.