The fraction of stars forming in compact, gravitationally bound clusters (the "cluster formation efficiency" (CFE)) is an important quantity for deriving the spatial clustering of stellar feedback and for tracing star formation using stellar clusters across the universe. Observations of clusters in nearby galaxies have revealed a strong dependence of the CFE on the local gas density, indicating that more stars form in star clusters when the star formation rate surface density is higher. Previously, it has not been possible to test this relation at very young ages and in clusters with individual stars resolved due to the universally low densities in the cluster-forming regions in the Local Group. This has even led to the suggestion that the CFE increases with distance from the Sun, which would suggest an observational bias. However, the Central Molecular Zone of the Milky Way hosts clouds with densities that are orders of magnitude higher than anywhere else in the Local Group. We report a measurement of the CFE in the highest-density region in the Galaxy, Sgr B2, based on Atacama Large Millimeter/submillimeter Array observations of high-mass young stellar objects. We find that over a third of the stars (37 ± 7%) in Sgr B2 are forming in bound clusters. This value is consistent with the predictions of environmentally dependent models for the CFE and is inconsistent with a constant CFE in the Galaxy.