I would suggest normally to have that kind of wiring, but your case is so weird, you could try with longer one. I remember some case with another brand ht sensor suffering from close contact to Esp (not thermally).
Anyway, like you can see there’s not a lot to offer at this point…
Esphome could have bug with sensor internal heater control, but just for Esp32, not so probable.
And I expect you have tried other pins already.
Hello I had the same problem as you. I think I managed to solve it. I did it by lowering l2c frequency to low value - 1000 Hz (default is 50khz) I also read the value every only every 3 minutes. I think the issue is that with high polling frequency the sensor itself heats up.