What are the conventions for going to a funeral at a church or other holy place outside of your faith/atheism? Is there a polite way to refuse touch on these situations?
That depends on the nature of your faith. Different traditions have different attitudes towards going into places of worship associated with other religions. And ultimately, it’s a matter of what your perspective on these things is.
One approach is that going to a funeral doesn’t necessarily have anything to do with religion or your religious beliefs. It can be about supporting people who are going through the awful experience of losing someone they care about. That’s generally understood to be one reason people go to funerals. Going to a funeral is not taken as a sign that you believe in that faith, just that you care about the people.
Most, but not all, religions make it possible to be in the service without actively participating in affirmations of faith. Because most religions accept that people have a legitimate reason to be present other than being part of that faith. For some people, that makes it ok to be at funerals in houses of worship that have very different values than their own - because they aren’t affirming that faith by being there; just supporting people in their grief.
But it’s also ok if your faith or atheism means that you’re unable to be present during the rituals of another faith. For some people, that’s really important. (It’s also important not to be a jerk about it.) If you’re not able to be present at the funeral, there are other ways you can offer support. For instance, calling them a few days later, or coming by, and checking how they’re doing and whether they want to talk. In some ways that can be more helpful than the funeral because sometimes people can be very alone and isolated after the public ritual has ended.
In terms of polite ways to avoid touch, it depends on which religious group you are talking about. Sometimes it is possible and sometimes it is not. When it’s not, it’s ok if that means you need to avoid that kind of service and find out ways to support mourners.
There is a useful book called How to be a perfect stranger that gives a guide to what’s likely to happen and be expected at various places of worship. That might be helpful in navigating these things.