The phone would have to have a temperature sensor, which is pretty rare -- as far as I know, the Pixel 8 Pro is one of the only phones that has one. You'd have to get a 3rd party temperature sensor that connects to your phone via an app.
I have one but it bases its reading on the chip temperature so you have to be quick, since using the phone for anything, including that, raises the chip temperature.