Is it a sin to mock or make fun of people, even as a joke or online?
Yes. Allah says: “O you who believe, let not a people ridicule another people; perhaps they are better than them… and do not insult one another or call each other by offensive nicknames” (49:11), and: “Woe to every slanderer and mocker” (104:1). The Prophet ﷺ said: “A Muslim is the brother of a Muslim. He neither oppresses him nor humiliates him nor looks down upon him. Piety is here” — pointing to his chest — “It is a serious evil for a Muslim that he should look down upon his brother Muslim.” This covers mocking someone’s looks, accent, family or poverty, hurtful nicknames, and memes or videos that make fun of a person. Light humour that hurts no one is fine. If you have mocked someone, delete what you posted, apologise to them, and make dua for them.
Evidence
يَـٰٓأَيُّهَا ٱلَّذِينَ ءَامَنُواْ لَا يَسۡخَرۡ قَوۡمٞ مِّن قَوۡمٍ عَسَىٰٓ أَن يَكُونُواْ خَيۡرٗا مِّنۡهُمۡ وَلَا نِسَآءٞ مِّن نِّسَآءٍ عَسَىٰٓ أَن يَكُنَّ خَيۡرٗا مِّنۡهُنَّۖ وَلَا تَلۡمِزُوٓاْ أَنفُسَكُمۡ وَلَا تَنَابَزُواْ بِٱلۡأَلۡقَٰبِۖ بِئۡسَ ٱلِٱسۡمُ ٱلۡفُسُوقُ بَعۡدَ ٱلۡإِيمَٰنِۚ وَمَن لَّمۡ يَتُبۡ فَأُوْلَـٰٓئِكَ هُمُ ٱلظَّـٰلِمُونَ
O you who have believed, let not a people ridicule [another] people; perhaps they may be better than them; nor let women ridicule [other] women; perhaps they may be better than them. And do not insult one another and do not call each other by [offensive] nicknames. Wretched is the name [i.e., mention] of disobedience after [one's] faith. And whoever does not repent - then it is those who are the wrongdoers.
وَيۡلٞ لِّكُلِّ هُمَزَةٖ لُّمَزَةٍ
Woe to every scorner and mocker
الْمُسْلِمُ أَخُو الْمُسْلِمِ لاَ يَظْلِمُهُ وَلاَ يَخْذُلُهُ وَلاَ يَحْقِرُهُ . التَّقْوَى هَا هُنَا . وَيُشِيرُ إِلَى صَدْرِهِ ثَلاَثَ مَرَّاتٍ بِحَسْبِ امْرِئٍ مِنَ الشَّرِّ أَنْ يَحْقِرَ أَخَاهُ الْمُسْلِمَ
Abu Huraira reported Allah's Messenger (ﷺ) as saying: … A Muslim is the brother of a Muslim. He neither oppresses him nor humiliates him nor looks down upon him. The piety is here, (and while saying so) he pointed towards his chest thrice. It is a serious evil for a Muslim that he should look down upon his brother Muslim. …
Source check: · Scholarly review: pending — no named reviewer yet