I think he had healing powers and kills a mimic in the dungeon that gives him the ability to reverse his magic to death magic.
Is this Nito's Lazy Foreign World Syndrome...?
Hidako Masamune is a high school student who suffers from continuous bullying by his classmates. Becoming tired of it all, he decides to commit suicide, but instead he is transported to another world along with all his classmates. When they arrive, they find that they now possess amazing abilities but he was only granted the status of a "healer," the weakest skill of all. The king decides to get rid of him by transporting him to another far away place, but not before Hidako swears revenge against the king, the kingdom, and all of his classmates.
As noted in the summary, the main character is summoned to a kingdom, along with a bunch of other students, but is subsequently cast out into a dungeon when they discover he's just a healer. (It's not strictly the queen that banishes him, but a female subordinate of the king.)
In that dungeon, he finds a room with some treasure chests in it. One of the chests has a magic potion in it that reverses the effect of his healing power and turns it into a deadly attack called 'Waves of Erosion.' Another is a mimic, i.e. a monster disguised as a treasure chest, which he kills with his new power.