The 12th house is associated with past life, bed pleasures, spirituality, moksha or salvation, expenditure, losses, lawsuits, hidden enemies, hospitalization, imprisonment, illicit sexual relationships, sorrows, etc.
The 12th house is the ultimate malefic house which can be problematic for any native; very few planets perform well in the 12th house and the house is quite literally so malefic that it is said that the lord of the 12th house itself will not only ruin the house He is placed in, but also destroy the other houses He aspects.
Mercury in the 12th house will not bestow much benefits to the individual materially at least. The only benefit a strongly placed Mercury in the 12th house could potentially offer is that the individual shall have expenses on good accounts, meaning that he/she will be a charitable person and will spend money to help uplift the poor or contribute money to social and religious causes. And this is the impact of a strong Mercury in the 12th house in its exaltation, meaning the ascendant is Libra. So, you can imagine what a poorly placed Mercury will do.
In the worst-case scenario, a debilitated Mercury in the 12th house, meaning in Pisces (so the ascendant will be Aries) will cause the individual to lose money severely due to both mismanagement as well as uncontrollable expenditure, and he/she will be a miser with regards to spending on themselves.
However, if Mercury is conjunct Ketu in the 12th house in a manner that Ketu is strongly placed, such as in Sagittarius (meaning the ascendant would be Capricorn), then the individual would be able to develop much occult power as Ketu functions perfectly in the 12th house. However, even in this conjunction, the individual would no doubt lose money or not have much material gains.
If Mercury happens to be the lord of the 12th house, meaning that the 12th house zodiac sign is either Virgo or Gemini, then Mercury will end up ruining the effects of whichever other house it is posited in.
The question of debilitation or exaltation does not arise here materially; Mercury in the 12th house will harm the individual in one way or the other, even if it forms a beneficial Yoga such as Sun Mercury conjunction or Budh Aditya Yoga.
The only relief one can expect from Mercury’s placement in the 12th house is if any benefic aspects are cast upon it. This includes aspects of the Moon, the Sun, Jupiter, and Venus. Saturn’s aspect on Mercury will do further damage to the losses and struggles, although Venusian aspects may cause the individual to be too much involved in illicit sexual affairs or end up seeking them.