The MAGPI Survey: forward modelled gas-phase metallicity gradients in galaxies at z ~ 0.3