The joke about the Masons demonstrates that Fortunato is from a more important family than Montresor.
We do not know much about Montresor, except that he is a madman and he wants revenge against Fortunato for some unknown, probably insignificant reason. Montresor gets Fortunato into the catacombs by telling him that he has a rare and expensive wine that he needs his opinion on. This may indicate that Fortunato is wealthier than Montresor, since he can be expected to know wine better.
Fortunato must not know Montresor well if he is trying to find out if he is a Mason. The Masons are an ultra-secretive secret society of wealthy and influential individuals. Montresor does not seem to have made the cut.
I broke and reached him a flagon of De Grave. He emptied it at a breath. His eyes flashed with a fierce light. He laughed and threw the bottle upwards with a gesticulation I did not understand.
I looked at him in surprise. He repeated the movement --a grotesque one.
Montresor likely describes the movement as grotesque because of his delusion. He considers Fortunato evil, worthy of punishment enough that he is trying to kill him. It makes sense that he would discount the movement Fortunato makes and read the wrong thing into it.
Fortunato presses the issue, and Montresor tries to backpedal. He does not want Fortunato getting suspicious now.
"You do not comprehend?" he said.
"Not I," I replied.
"Then you are not of the brotherhood."
"You are not of the masons."
"Yes, yes," I said; "yes, yes."
"You? Impossible! A mason?"
Fortunato’s contempt shows that he does not believe Montresor, and does not value Montresor’s family name. Montresor tries to get out of the situation by holding up his trowel. Fortunato is drunk enough to think it is part of a joke and not wonder what Montresor is doing with a trowel.
The Mason incident is effective in that it adds comic relief, foreshadowing, and characterization. It is humorous, but it also foreshadows the danger to Fortunato. Why does Montresor have that trowel? It is also characterization, because it tells us that Fortunato's family is wealthier and more influential than Montresor's.