Depends on 3 things:
- How hard can you brake (how much friction between the brake and the wheel)?
- Do the wheels skid (how much friction between the tire and the ground)?
- Does the rider go over the handle bars?
Do the wheels skid (how much friction between the tire and the ground)?
Assuming sufficiently-strong brakes (and maybe any legal brakes are sufficiently strong, e.g. in some jurisdictions the brakes are required to be strong enough to skid the back wheel), the 2nd of the above (i.e. friction of tire on ground) often seems to be the limiting factor. Then the distance is (theoretically) independent of mass -- the heavier the bike, the greater the friction (per Amontons' first law), thus the mass cancels out so that minimum distance is independent of mass -- because with greater mass you need more stopping force, but you have correspondingly more friction.
Amontons' first law is just an approximation (but maybe a good one), which you might want to check with real-world experiments (different tires, weights, road surfaces).
Does the rider go over the handle bars?
I think though that, assuming good brakes, the front wheel generally won't skid (and the back wheel will, if the back brake is applied) because with any deceleration the apparent weight moves forward, off the back wheel onto the front.
And so the bike will stop and the rider won't (so the rider will go over the handle-bars); or the bike will fish-tail if the back brake is applied (the front stops while the back skids).
Therefore (assuming sufficient braking) what actually matters is the position of the rider: the rider should be low and as far back as possible during an emergency brake -- so that their centre of mass is as far behind the front wheel as possible.
image from How to Brake on a Bicycle
Since few riders ever brake this hard, how come they still go over the bars? Here is what appears to happen to most riders who go over the bars: If riders don’t brace themselves against the handlebars, their momentum will push them forward over the handlebars as the bike slows. (Imagine being a passenger in a car without a seatbelt as the driver brakes hard.)
To avoid this, Hahn in the photo above braces himself against the handlebars and locks his elbows. He has shifted his weight as far back as possible. You can see his bicycle’s saddle underneath his belly. With this technique, he did not “go over the bars.” And if your bike’s rear wheel does lift, it happens slowly enough that you can counter it by slightly releasing the front brake lever.
Theoretically, if riders' positions are equal, a heavier bike might stop better (skid or flip less easily) because that lowers the centre of mass of the rider+bike combination; in practice I doubt whether this is a large/important effect, because a rider is a fair bit heavier (and higher) than any bike.
Another way in which mass may affect braking is that over-braking may (excess heat) burn out the brake -- but I think that's unusual and only tends to happen on a long down-hill, e.g. alpine touring, or possibly with cargo bikes or tandem cycles.
How hard can you brake
The article cited above says,
Very, very hard. We found that to get the shortest stopping distance, we had to pull the front brake lever with all our might. Witness the tester’s bulging muscles on his right arm [...] When we came to a stop, the smell of burnt brake pads wafted through the air. After 21 full-on emergency braking maneuvers, the Aheadset of the test bike had developed play [...]
Perhaps that's typical of road (racing) bikes, which are optimised more for going than for stopping. My experience is with hydraulic disk brakes (which are more common than rim brakes on cargo bikes, tandems, mountain bikes, touring bikes ), which feel like they could stop a truck (or at least, stop the front wheel without much effort, and therefore require a bit of caution in their use).