Thermodynamics is the phenomenological theory of heat and work. Here we analyze to what extent quantum thermodynamic relations are immune to the underlying mathematical formulation of quantum mechanics. As a main result, we show that the Jarzynski equality holds true for all non-hermitian quantum systems with real spectrum. This equality expresses the second law of thermodynamics for isothermal processes arbitrarily far from equilibrium. In the quasistatic limit however, the second law leads to the Carnot bound which is fulfilled even if some eigenenergies are complex provided they appear in conjugate pairs. Furthermore, we propose two setups to test our predictions, namely with strongly interacting excitons and photons in a semiconductor microcavity and in the non-hermitian tight-binding model.