Why do we care?
In theory, lenses send the focus distance information to the camera. It is recorded as an EXIF metadata in the file. Using it can have different advantages if you are interested in the distance at which the photo is supposed to be in focus.
Short answer
You need to try with you own gear, but it is very unlikely that you can trust, even just a little bit, the information provided about the focus distance.
Long answer
This is well known fact. In many forum, people often report you can’t trust this distance information. But it is good to be sure. So, I did some tests with the following gears: Nikon D750, Nikon Z50, and different lenses (20 mm f/1.8G, 70-200 f/2.8 II, …). All came to the same conclusion: the distance recorded is really not accurate. How much inaccurate ? Let me give you the results:
Example 1
In reality, the image is at infinity focus, not 1.3 meters like written into the EXIF metadata…
Example 2
This one was pretty accurate, to be fair.
With a Nikon Z50, you just don’t have the focus distance recorded. Same issue with some mirrorless cameras like Panasonic LX100 or Fuji X100S.
I have also tried with different Canon bodies, but same problem: not too bad at very close distance, but totally irrelevant as soon as the distance focus is above a couple of meters.
Conclusion
Make your own tests with your gear, but don’t expect much.
There is some hope if what matters is distance of images with a focus distance below a few meters. But beyond this, I would find a different way to achieve the goal, whatever it may be as the focus distance information is irrelevant, when it exists.