The prompt D0 meson azimuthal anisotropy coefficients, v2 and v3, are measured at midrapidity (|y|<1.0) in Pb-Pb collisions at a center-of-mass energy √sNN=5.02 TeV per nucleon pair with data collected by the CMS experiment. The measurement is performed in the transverse momentum (pT) range of 1 to 40 GeV/c, for central and midcentral collisions. The v2 coefficient is found to be positive throughout the pT range studied. The first measurement of the prompt D0 meson v3 coefficient is performed, and values up to 0.07 are observed for pT around 4 GeV/c. Compared to measurements of charged particles, a similar pT dependence, but smaller magnitude for pT < 6GeV/c, is found for prompt D0 meson v2 and v3 coefficients. The results are consistent with the presence of collective motion of charm quarks at low pT and a path length dependence of charm quark energy loss at high pT, thereby providing new constraints on the theoretical description of the interactions between charm quarks and the quark-gluon plasma.