I guess it's possible because on the climbs you need to beat gravity more than the wind resistance but is there a formula to calculate how much the weight of the rider affect the climbing performance?
Yes. This article goes into detail and shows the formula along with a few scenarios.
In short, power-to-weight ratio becomes more important than raw power as the grade increases. Aerodynamic drag is still a factor, so the advantage to the rider with better power-to-weight is mitigated.
Yeah, those lightweight powerhouses do great on the climbs but then they get hit on the descents, where higher weight gives an advantage. Look up Jean Robic, famous post-WW2 Tour de France winner, little guy, very light and very strong, amazing on the ascents, and then as he hit the top his team would pass him water bottles, as they do, but filled with lead shot. After the organizers got wise and banned solid metal "water" he switched to mercury.