Event-shape engineering analysis of D meson in ultrarelativistic heavy-ion collisions