I won’t disagree that Hamlet, Prince of Denmark, c. 1300, was Catholic.
Yes good point.
Right, but the reference to purgatory is a part of the plot and Shakespeare presents it as a fact of life, not as some quaint belief of yet-unenlightened Prince Hamlet. Further, the call to revenge is tied to the purgatorial suffering:
I am thy fathers spirit,
Doomed for a certain term to walk the night
And for the day confined to fast in fires,
Till the foul crimes done in my days of nature
Are burnt and purged away. But that I am forbid
To tell the secrets of my prison house,
I could a tale unfold whose lightest word
Would harrow up thy soul, freeze thy young blood,
Make thy two eyes, like stars, start from their spheres,
Thy knotted and combinèd locks to part
And each particular hair to stand on end,
Like quills upon the fearful porpentine.
But this eternal blazon must not be
To ears of flesh and blood
...
Revenge his foul and most unnatural murder.
I think that’s how Shakespeare got away with it to a large extent. Though he still walked a tightrope, which undoubtedly was nearly as thrilling to his audiences.