It's actually for this reason that for hundreds of years until the early 21st century there was real concern about having a Catholic prime minister. There was even hand-wringing over PMs of other denominations, but the history of Catholicism in the UK in particular raised concern. Why? The PM has final approval of the Lords Spiritual - the bishops from the Church of England who are there to provide a protestant spiritual dimension to all debates before that House.
It's allegedly for this reason that Tony Blair (married to a Catholic) waited until after he left office to convert. I think it was either Brown or Cameron who then got the law explicitly changed to not bar Catholics and other religions to serve as PM.