The unit should just follow the same religion as their Noble. It would be an unnecessary pain in the butt if you have to calculate how prevalent a religion is in each region and then assign troops originating from that region a preferred religion. Way too complicated a process for a small game mechanic.
If a noble follows your religion and you bless their unit: boost morale
If a noble is a pagan or different religion: chance of getting beaten up
Nice and simple. I don't think it needs to be as complicated as 12 infantry are religion x and 16 are religion y.