Electromagnetic fields in small systems from a multiphase transport model