I made a decision when I started writing The Righteous that I would take my religious characters seriously. That meant they weren't deluded fools or brainwashed or any of the other tropes that you frequently see in writing about religion (as opposed to religious writing, which has its own issues). That meant that even my evil characters must have clear justification, that they had to frame their actions in terms of their religious background. These people did not consider themselves mustache-twirling (beard-twisting?) villains, they were serving God's purpose. Never mind that other characters thought they were serving God's purpose or looked at these people as clear villains. In their own mind, they were the heroes of the story.
This last line bears repeating. Every person considers himself the hero of the story. There's a great line in Shakespeare in Love where Shakespeare has turned the nasty financial backer into a true patron by giving him a minor part in the play. Someone asks this guy what Romeo and Juliet is about and he says, "There's this apothecary..."
Remember, too, that no person is merely part of a group. She isn't Chinese, or a paraplegic, or a doctor, or, in my Righteous series, a polygamist. These things may shape her view of the world, but she is smart or stupid, kind or cruel, thoughtful or careless, or anything else largely independent of her surroundings. In fact, I sometimes find it interesting to write characters in direct opposition to what they should be. A thoughtful, but patriotic German living under the Nazi regime is much more interesting than yet another cruel Gestapo agent. Now pit him against a cruel Gestapo agent, but work like hell to justify that agent's behavior. What is the story our antagonist tells himself? How does he frame the narrative to make him the hero of the story? There are numerous ways, all of them more interesting than the guy who says "Ve have vays of making you talk..."
If you take every character seriously, you can write about all sorts of people without making them sound either like stereotypes or--almost as bad--politically correct reversals of stereotype. I love writing from the POV of people very different than myself. My four favorite characters are the aforementioned patriotic German (The Red Rooster), the favorite son of a cult leader and his bright, believing younger sister (The Righteous), and a guy whose only means of communicating with the outside world is a single, blinking eye (The Devil's Deep). Of these four, Jacob from The Righteous resembles me quite a bit, assuming I were smarter, better looking, and more charismatic, but the other three are very different from me.
I guess you could say that I ignore the advice to write what you know, but that's another post entirely.