It can of course be scripted in the spells so... lets say... it's no longer possible to cast friendly spells on followers of enemy deities, or that there is a certain % chance for something to happen if it's done.
Actually, that would be rather easy to do. But then, one can ask oneself, why is it not done?
Well, the answer is very simple: Scripts cannot detect the RP situation by itself.
Different deities handle punishments in different ways, and on the basis of what they consider out of line and what's not isn't the same.
And lastly, we have that the punishments from the deities are mostly in RP nature, and not shown in any game mechanic sense (except for if you get your deity field wiped, that is). For example, being talked to by another cleric of the same faith, or suddenly having some nightmares about what was done...
The choice of whether to have scripted penalties or not is like the choice of whether having scripted quests or DM run ones! The first being 110% fair while the later is surely more fun, even though at times they can be perceived as unfair (like one DM allows X but not Y and another DM allows the opposite)...