For cycling and running, your VO2max can be estimated from either average power or distance ran during a short maximal effort (3 to about 12 minutes).
In cycling, you require an accurate power meter or smart trainer. The former measures the amount of torque you apply to the crankarms, and converts this to power. Smart trainers measure the same concept at the trainer's flywheel. Some gyms have Stages bikes, which produce credible power meters but which is going out of business. In this answer on the Bicycles Stack Exchange, I discussed some methods, but briefly, you warm up, then you do an all-out 5 minute effort. You can then use the following equation:
VO2max in L/min = 0.0108 x power (W) + 0.007 x body mass (kg)
Note that the output is in liters, not the usual milliliters (mL), and it is not normalized to body mass. Alternatively, if you're on Zwift, if you do a short (I think 3-6 minute) maximal effort, it will estimate your VO2max using a similar formula (I got similar results from both formulas).
There probably are other similar formulae out there. Note that in all cases where you use a formula like this, there is some prediction error. For example, in the other answer, one different cycling prediction equation (this using maximal power from a ramp test, which you can conduct on a cycling smart trainer), the equation should predict VO2max for most fit men within a range of 8.32 mL O2/min kg overestimate or 15.52 unit underestimate, with most people falling closer to their actual value. Not all formulas have their prediction errors estimated. You might find these in peer-reviewed papers, but it can be hard to search.
Running power is not widespread as there's no specific thing that they can mount strain gauges to. However, you can estimate VO2max from distance covered in a maximal effort, probably better in a more controlled setting like a track. One example is the Cooper Test, a 12-minute maximum run. Where d is the distance covered in meters, a VO2max estimate is
(d - 504.9) / 44.73
With all such tests, pacing is important, and beginners may not know how to pace a maximal effort. A mis-paced effort should tend to under-estimate your true VO2max. I suspect the issue is a bit worse for longer efforts. Not being used to pushing yourself to the max will also tend to produce under-estimates.
One can imagine other sports like maybe indoor rowing where you could conceivably get a VO2max estimate. Interested parties should check the peer-reviewed literature or Google. There may be the issue of variations between equipment to consider, which might throw off the estimate.
Last, VO2max tests are increasingly available. One lab near me charges $3-400 for a VO2max test plus some other tests that may be useful for some sports. The local university sports science lab charges less. Readers can determine for themselves if this is worth the cost. Readers who are serious endurance athletes might not want to spend that money; their VO2max is very likely to be above average, and while VO2max is very strongly linked to mortality, the returns are diminishing. It is very important to avoid having a low or very VO2max. However, if your aerobic fitness is very low, then essentially anything is likely to improve it. Walking 10 minutes a day is likely to help someone who's literally starting from the couch. Naturally, you need to overload progressively to keep increasing your fitness. The point is that you may not necessarily need to quantify your VO2max to motivate yourself to keep progressing. You could consider assessing yourself by things like what's the longest hike or bike ride I did this year.