Mocking religion is a major sin and is transgressing the sacred limits of Allah, and is one of the areas of disbelief that many of the ignorant and base people fall into without realising. Allah, may He be exalted, says (interpretation of the meaning):
“The hypocrites fear lest a Soorah (chapter of the Qur’an) should be revealed about them, showing them what is in their hearts. Say: ‘(Go ahead and) mock! But certainly Allah will bring to light all that you fear.’
If you ask them (about this), they declare: ‘We were only talking idly and joking.’ Say: ‘Was it at Allah, and His Ayat (proofs, evidences, verses, lessons, signs, revelations, etc.) and His Messenger (blessings and peace of Allah be upon him) that you were mocking?’
Make no excuse; you have disbelieved after you had believed. If We pardon some of you, We will punish others amongst you because they were Mujrimoon (disbelievers, polytheists, sinners, criminals, etc.)”
Imam Ibn Hazm az-Zaahiri said:
It is proven by sound texts that anyone who mocks Allah, may He be exalted, or any of the angels or Prophets (peace be upon them), or any verse of the Qur’an, or any of the obligatory duties of religion after proof has reached him, is a disbeliever.
Shaykh Sulaymaan Aal ash-Shaykh said:
Whoever mocks Allah, His Book, His Messenger or His Religion becomes a disbeliever, even if he did not really intend to mock them, according to scholarly consensus.
Mocking the religion includes all words and deeds that are indicative of casting aspersions upon, ridiculing and belittling the religion.
Abu Haamid al-Ghazaali said:
What is meant by mockery is ridiculing, belittling, and pointing out faults and defects by way of laughing at something, and that may be done by in word and deed, or by pointing and gesturing.
Any word or deed that is indicative – according to what is customary among people and what they understand in their language – of belittling or ridiculing Allah and His Messenger, or the Qur’an and Sunnah, or any of the symbols of this religion, comes under the heading of mockery that puts one beyond the pale of Islam.
Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) said:
As there is no set definition of reviling in either linguistic or Islamic terms, reference concerning that should be made to what is customary among people. Whatever is customarily regarded as reviling of the Prophet is that to which we must apply the words of the Sahaabah and scholars. Whatever is not like that is not subject to those rulings.
If the words or deeds are not indicative of ridicule, belittling and scorn, then they do not come under the heading of mockery that puts one beyond the pale of Islam.
Mockery may come under the heading of sin rather than disbelief, such as mocking a Muslim person for what he is. But if someone mocks him for his religious commitment or for his appearance that is in accordance with the Sunnah, then this is a serious matter which in some cases may constitute disbelief – Allah forbid.
What the Muslim must do, if he hears or sees any kind of mockery of religion, is to sternly denounce the one who says or does that, and if he does not respond then he must leave the place where he is. Allah, may He be exalted, says (interpretation of the meaning):
“And it has already been revealed to you in the Book (this Qur’an) that when you hear the Verses of Allah being denied and mocked at, then sit not with them, until they engage in a talk other than that; (but if you stayed with them) certainly in that case you would be like them. Surely, Allah will collect the hypocrites and disbelievers all together in Hell”
With regard to smiling or laughing when hearing such words, that makes the one who does it a partner in sin with the one who says them, if it stems from his being pleased with and accepting those things, as Allah, may He be exalted, says: “certainly in that case you would be like them” [an-Nisa’ 4:140]. But if it did not stem from his being pleased with and accepting those things, then it is a major sin which indicates that reverence for Allah and His symbols is not firmly established in his heart.
What the Muslim must do is honour the symbols of Allah’s religion and the revelations of Allah, and venerate them and hold them in the highest esteem, as Allah, may He be exalted, says (interpretation of the meaning):
“And whosoever honours the Symbols of Allah, then it is truly from the piety of the heart”
Al-‘Allaamah as-Sa‘di said:
The basis of religion is founded upon reverence for Allah and honouring of His religion and His Messengers. Mocking any of these things is contrary to that basic principle and is diametrically opposed to it.
And Allah knows best.
(Source - Islam Q&A)