When being sarcastic, usually what is being said is opposite to the truth but in an expression or tone which can give away that one is being sarcastic. So is it considered forbidden and same as lying?
You can divide sarcasm into two types:
Not involving lying
The second is in the Quran itself, so that is definitely halal:
Those who defy Allah’s signs and kill the prophets unjustly, and kill those who call for justice from among the people, congratulate them of a painful punishment. (3:21)
The word used here for "congratulate" is بَشِّر, and a commentary on what it means:
ما البِشارَةُ ؟ الجَوابُ: أنَّها الخَبَرُ الَّذِي يُظْهِرُ السُّرُورَ، ولِهَذا قالَ الفُقَهاءُ: إذا قالَ لِعَبِيدِهِ: أيُّكم بَشَّرَنِي بِقُدُومِ فُلانٍ فَهو حُرٌّ، فَبَشَّرُوهُ فُرادى عُتِقَ أوَّلُهم؛ لِأنَّهُ هو الَّذِي أفادَ خَبَرُهُ السُّرُورَ، ولَوْ قالَ مَكانَ بَشَّرَنِي: أخْبَرَنِي، عُتِقُوا جَمِيعًا؛ لِأنَّهم جَمِيعًا أخْبَرُوهُ، ومِنهُ البَشَرَةُ لِظاهِرِ الجِلْدِ، وتَباشِيرُ الصُّبْحِ: ما ظَهَرَ مِن أوائِلِ ضَوْئِهِ، وأمّا ﴿فَبَشِّرْهم بِعَذابٍ ألِيمٍ﴾ [آل عمران: ٢١] فَمِنَ الكَلامِ الَّذِي يُقْصَدُ بِهِ الِاسْتِهْزاءُ الزّائِدُ في غَيْظِ المُسْتَهْزَأِ بِهِ، كَما يَقُولُ الرَّجُلُ لِعَدُوِّهِ: أبْشِرْ بِقَتْلِ ذُرِّيَّتِكَ ونَهْبِ مالِكَ.
What is Bishaarah? Answer: It is a news that brings happiness [...] As for "congratulate them of a painful punishment" (3:21), it is a mocking phrase that increases the severity on the one being mocked. It is similar to how a man would say to his enemy, "Congratulations on the death of your children and destruction of your wealth." (Tafsir Ar-Razi)
As you can see, Allah did not make any lying statement, but the sarcasm was instead with his word choice of using 'congratulate' for a punishment.
But, the other type of sarcasm is basically lying but meaning the opposite. Something like this:
Person A: You have got to believe me!
Person B: Sure, I believe you.
This type is not good and should be avoided. Lying is a sin in Islam:
The Prophet (ﷺ) said, "Whoever does not give up false statements (i.e. telling lies), and evil deeds, and speaking bad words to others, Allah is not in need of his (fasting) leaving his food and drink." (Sahih Bukhari)
"The sign of a hypocrite is that whenever he speaks he lies, and whenever he makes a promise he does not fulfill it, and if he is entrusted he betrays." (Jami Tirmidhi)
"Woe to the one who talks about something to make the people laugh, in which he lies. Woe to him! Woe to him!" (Jami Tirmidhi)
Abdullah said, "Lying is not correct, neither in seriousness nor in jest. None of you should promise his child something and then not give it to him. (Adab Mufrad)
"They said: 'O Messenger of Allah! You joke with us?' He said: 'Indeed I do not say except what is true.'" (Jami Tirmidhi)
It is still considered lying regardless of the unsaid meaning.
The third hadith above clinches it since the Prophet (SAW) did not even allow lying for humor, and sarcasm at its best is humorous and at its worst creates negative feelings between people. So, it is not allowed so much that the Prophet (SAW) cursed the one who does it.
A deliberate lie can be defined as an untrue statement meant to deceive. Since when are being sarcastic, the meaning is understood by both parties, it cannot be called a deliberate lie, same as fiction or figurative language cannot be called a lie. What matters is your intention to convey the truth and not get laughs by fabricating a false story since that is prohibited in Islam.
The Prophet (Pbuh) said : " Woe to him who speaks and tells lies so as to make people laugh thereby. Woe to him! Woe to him!"
I hope this time my answer is satisfactory
Lying refers only to actual lies where the intent is to deceive.
For more information, I am quoting : the Fatwa Department Research Committee - chaired by Sheikh `Abd al-Wahhâb al-Turayrî
Sarcasm is to say something with an underlying insulting or caustic implication. Irony is a form of expression in which an understood implicit meaning is concealed or contradicted by the explicit meaning of the expression. Sarcasm is often used in conjunction with irony. Both of these modes of speech are often conveyed with a particular vocal intonation when spoken and are sometimes rendered with italics when written, like in: “Great! That’s all I need!” or “Oh, very funny”.
What matters is the honesty of the meaning that is being conveyed by the communication, not the literal implications of the words.
For instance, in the example that you give in your question, a person is writing something down. The onlooker can see this, but asks: "Are you writings something?"
The person who is writing responds to the onlooker’s question by saying: “No, I am playing football.”
What he means is: “Of course I am writing, and it is silly of you to ask.” This is the meaning that is communicated and understood.
In English, there are some phrases that are always ironic. Consider when a person says: “Big deal” or “Wise guy”.
Therefore, ironic and sarcastic statements are not lies, any more than figurative speech is a lie. "He was a lion on the football field" is a figurative statement, not a lie - though certainly the football payer is not a great cat.
In the same way, irony and sarcasm are recognized modes of speech which convey an intended meaning understood by both the speaker and the listener.
Irony and sarcasm are therefore quite different than a joke that is a deliberate lie, where the teller of the joke means to communicate a falsehood. Whether or not the listener is aware that it is a lie, what matters is that the speaker fully intends to communicate by what he says a meaning that is false, with the intention of provoking laughter on account of that falsehood.
And Allah knows best.
The following video provided greater insight on how to joke without crossing boundaries https://www.youtube.com/watch?v=6dPI4W5XZlk (Yasir Qadhi - Joking in Islam)