It's....difficult, what do you count as zero altitude? Theoretically we count it from sea level, there are areas on earth below sea level so they measure in the negative, but there is no water on these bodies, so you are going to have to decide on a point on the surface to count as zero. If you take the average height across the surface that not going to work for how high is a mountain. What I would suggest is that the player can set the point they are at as zero and measure above and below that, but an altimeter would be difficult to implement accurately. That way the player can just set zero and climb that mountain to see how high it is!
What I do now (and I guess everyone else), is measure heights but just using the vertical thrusters of my ship, while keeping it horizontal.
With regards to an absolute altitude however, the problem would be indeed determining what is the reference geoid (on Earth we use sea level, but that's just a convenience, and is generally a barometric measurement).
This is now purely in the realm of speculation, but my guess is that the game has in fact a reference sphere for each planet, and a height map is applied to it.
That could be the starting point. Every planet has a radius clearly stated on its information sheet.
Moreover, when we approach a planet, we can see how the gravity pull changes with the distance to its centre: there has to be a (very basic) gravimetric gradient and therefore a reference point (the centre of the planet, I suppose for these calculations the planet is considered to have its mass all in its central point, rather than a three dimensional distribution): at any point, the game knows how far we are from it, because the gravitational pull (already shown on our HUD) changes with altitude. (Notwithstanding the fact that a change of a few meters will not affect the number shown on the gauge because it is well below its sensitivity - by design).
I am not saying it is not hard, but all things considered, I don't think it is such an outlandish suggestion, considering that most of this information is already available in game in some form or another.