The GPS in the phone can give elevation data. But you need to use an app to display it. Various mapping, hiking, etc., apps will let you see that data. I use an app called GPS Essentials that I've had for years for that kind of thing. It does have ads now, though. There are probably a lot of similar apps, but this one does a lot.
It even shows barometric pressure and barometric altitude as well. That implies that these phones have a barometric sensor on board, but I have not verified that!
I also use a backpacking/hiking app that shows elevation, as well as a GPS mapping app that let's you download and use offline topo maps along with the GPS functions so the phone can behave as a hiking GPS does, without needing to have access to cell service. That's nice.
I also believe that some of the sky map apps show your coordinates as well as elevation.
So there are a lot of apps you could use to display elevation, and perhaps barometric altitude as well. But again, I have not verified how the barometric data is obtained. And of course, you would need to calibrate that to the local "station pressure" ( not the same as weather station barometric readings which are corrected to sea level no matter where the station is located).