Point Position Map
as reaction to your comment about concave/convex distortion ... Height map is calculated from zero elevation in up (Normal Z) direction. If your mesh state with some topology below base mesh surface you would have to use Point Position Map instead of Height Map (if I'm right).
Here is an example of Point Position Map baked from modified default Torus object:
- I'm skipping first two steps of previous answer with Vertex Distance.
- Default Torus is just deformed in concave/convex direction to see effect
- Bake type Position (as usual -keep Image Texture node selected)
Note: When hit New texture type Generated be sure 32-bit Float is checked! Othewise data will be cropped and your displacement ends with just a part of mesh since data will contains only positive values from 0-1 on XYZ).

Bake used by Displacement material
(enable Experimental Features, under Material > Settings > Suface > Displacement switch to Displacement Only) on Torus B

Comparison

Bake used dy Displacement modifier
In edit mode scale all vertices to zero, add modifier (see image), under texture properties don't forget to uncheck Colour > Clamp otherwise you get only quarter of torus :).

The reason to scale vertices at zero location is that Point Position Map refers by colour to position point in a global space, but used by any displacement the value is added on top of existing point position.
When used by Microdisplacement (described above) it can be compensated by vector Subtract math node, but when this map is used by Displacement modifier there is not such option to math this kind of compensation.
Tip: Scale from zero to original shape back is not possible off course, so if you want to preserve original shape you can use Shape Keys :)
Both versions ...

Later I will try to check GN ...