I only remember an example of Dionysus written by Aristophanes and it's a god who probably wouldn't mind to be laughed at. But there must have been others. Do we know anything about playwriters being punished for lack of respect of gods?
You're right, many of Aristophanes's plays feature gods as characters, and make comedy out of these characters as well as of various religious rituals and practices. As far as we know, this kind of representation of the gods didn't offend anyone, and there is a rich tradition of humorous portrayal of the gods throughout the Greco-Roman world (for example Lucian, a Greek writer in the Roman Empire).
There are lots of possible reasons for this, all of which we have to guess to some extent because we don't have surviving contemporary opinions on the plays themselves.
Relevant features of ancient Athenian society include the common portrayal of the gods in visual and literary arts (it wasn't a religious system that frowned on representing the divine), the existence of a variety of 'subversive' rituals and practices in Ancient Greek religions (such as the Dionysia) and the existence of humorous tellings of various myths dates as far back as Homer (in his depiction of squabbling on Olympus or Hera's jealous seduction of Zeus in The Iliad for example). Paul Cartledge's Aristophanes and His Theatre of the Absurd gives a good, accessible overview to the way Athenian society and culture shaped the plays.
The nature of the plays and their role as part of a religious festival are also really key here. First, Aristophanic humour pokes fun at all authority figures, so the gods fit within a broader social structure that is being mocked. Second, the plays were performed as part of the worship of Dionysus, whose cult included different sorts of role reversal and subversion at different times (see Winkler & Zeitlin's collection "Nothing to do with Dionysos?"). The festival included processions of phalluses, demonstrations of Athenian strength and wealth and, of course, the tragic and comic play competitions. This massive event took Athenians out if the day to day and gave them permission to laugh at all the scariest/bleakest stuff in their lives (Aristophanes also jokes about war, suicide, rape, politics...). Indeed, Aristophanes even made ridiculing the rural version of this festival (the rural Dionysia) one of the jokes themes of his play, The Archarnians.
So yes, gods were laughed at. As far as we know, people in general weren't offended, because culturally it made sense for it to happen in this context. Scullion's Religion and the Gods in Greek Comedy can give you more detailed analysis of how the gods were portrayed overall.