The non-spherical shapes of dark matter and gas distributions introduce systematic uncertainties that affect observable-mass relations and selection functions of galaxy groups and clusters. However, the triaxial gas distributions depend on the non-linear physical processes of halo formation histories and baryonic physics, which are challenging to model accurately. In this study we explore a machine learning approach for modelling the dependence of gas shapes on dark matter and baryonic properties. With data from the Illustris-TNG hydrodynamical cosmological simulations, we develop a machine learning pipeline that applies XGBoost, an implementation of gradient boosted decision trees, to predict radial profiles of gas shapes from halo properties. We show that XGBoost models can accurately predict gas shape profiles in dark matter haloes. We also explore model interpretability with SHAP, a method that identifies the most predictive properties at different halo radii. We find that baryonic properties best predict gas shapes in halo cores, whereas dark matter shapes are the main predictors in the halo outskirts. This work demonstrates the power of interpretable machine learning in modelling observable properties of dark matter haloes in the era of multi-wavelength cosmological surveys.