I had the same thought until PS corrected me. I started thinking about it in the sense of thermodynamics. To put it simply, if the cylinder temperatures got hotter as the mixture was leaned out then the absence of any fuel would result in infinite heat
Now we know that won't work. Unfortunately.
Thinking of small aircraft, as you ascend you would lean the mixture to account for less dense air. As you do so the exhaust gas temp increases, yes. Not because lean= hotter, but because the excess fuel acts as a coolant. It absorbs the heat. As the mix is leaned out there is less "coolant" (vaporizing fuel) and the EGT goes up. However, only so far. If the mix is leaned further then it starts dropping (less fuel, less work, less heat) until combustion can no longer be supported.