The dependence of stellar molecular bands on the metallicity is studied using infrared L-band spectra of AGB stars (both carbon-rich and oxygen-rich) and M-type supergiants in the Large and Small Magellanic Clouds (LMC and SMC) and in the Sagittarius Dwarf Spheroidal Galaxy. The spectra cover SiO bands for oxygen-rich stars, and acetylene (C2H2), CH and HCN bands for carbon-rich AGB stars. The equivalent width of acetylene is found to be high even at low metallicity. The high C2H2 abundance can be explained with a high carbon-to-oxygen (C/O) ratio for lower metallicity carbon stars. In contrast, the HCN equivalent width is low: fewer than half of the extra-galactic carbon stars show the 3.5 µm HCN band, and only a few LMC stars show high HCN equivalent width. HCN abundances are limited by both nitrogen and carbon elemental abundances. The amount of synthesized nitrogen depends on the initial mass, and stars with high luminosity (i.e. high initial mass) could have a high HCN abundance. CH bands are found in both the extra-galactic and Galactic carbon stars. One SMC post-AGB star, SMC-S2, shows the 3.3 µm PAH band. This first detection of a PAH band from an SMC post-AGB star confirms PAHs can form in these low-metallicity stars. None of the oxygen-rich LMC stars show SiO bands, except one possible detection in a low quality spectrum. The limits on the equivalent widths of the SiO bands are below the expectation of up to 30 A for LMC metallicity. Several possible explanations are discussed, mostly based on the effect of pulsation and circumstellar dust. The observations imply that LMC and SMC carbon stars could reach mass-loss rates as high as their Galactic counterparts, because there are more carbon atoms available and more carbonaceous dust can be formed. On the other hand, the lack of SiO suggests less dust and lower mass-loss rates in low-metallicity oxygen-rich stars. The effect on the ISM dust enrichment is discussed.