We present the comparison of the three most important ice constituents (water, CO and CO2) in the envelopes of massive Young Stellar Objects (YSOs), in environments of different metallicities: the Galaxy, the Large Magellanic Cloud (LMC) and, for the first time, the Small Magellanic Cloud (SMC). We present observations of water, CO and CO2 ice in 4 SMC and 3 LMC YSOs (obtained with Spitzer-IRS and VLT/ISAAC). While water and CO2 ice are detected in all Magellanic YSOs, CO ice is not detected in the SMC objects. Both CO and CO2 ice abundances are enhanced in the LMC when compared to high-luminosity Galactic YSOs. Based on the fact that both species appear to be enhanced in a consistent way, this effect is unlikely to be the result of enhanced CO2 production in hotter YSO envelopes as previously thought. Instead we propose that this results from a reduced water column density in the envelopes of LMC YSOs, a direct consequence of both the stronger UV radiation field and the reduced dust-to-gas ratio at lower metallicity. In the SMC the environmental conditions are harsher, and we observe a reduction in CO2 column density. Furthermore, the low gas-phase CO density and higher dust temperature in YSO envelopes in the SMC seem to inhibit CO freeze-out. The scenario we propose can be tested with further observations.