Ridiculing Allah, His Religion, Messenger, or any of His prophets is an act of apostasy from Islam. Allah (Exalted be He) states,
Say: "Was it at Allâh (عز وجل), and His Ayât (proofs, evidence, verses, lessons, signs, revelations) and His Messenger (صلى الله عليه وسلم) that you were mocking?"
Make no excuse; you disbelieved after you had believed.
Therefore, we should beware of this, even if it is done in a joking manner. Allah has mentioned what these people say,
We were only talking idly and joking.
But despite that, He has not excused them.May Allah grant us success. May peace and blessings be upon our Prophet Muhammad, his family, and Companions.