Based on reference paper given above, the reference system of interest here is $\ce{Zn_{22}M_{2}O_{24}}$.
As two $\ce{Zn}$ atoms were substituted by transition metal ($M=\ce{V}, \ce{Cr}, \ce{Mn}, \ce{Fe}, \ce{Co}, \ce{Ni}).$ Formation energy for doping is given as
$E_f = E(doped_{\ce{ZnO}}) -E_{\ce{ZnO}}+2(\mu_{\ce{Zn}}-\mu_{\ce{Ni}}) $ where $ E(doped_{\ce{ZnO}})$ is total energy of $\ce{Zn_{22}M_{2}O_{24}}$ and $E_{\ce{ZnO}}$ is energy of $\ce{Zn_{24}O_{24}}$. The chemical potentials of the $\ce{V}$, $\ce{Cr}$, $\ce{Mn}$, or $\ce{Fe}$ are energies of single atom in the body centered cubic structure, where as in case of $\ce{Co}$ and $\ce{Ni}$, hexagonal crystal structure and face centered cubic structure were considered respectively. For $\ce{Zn}$ they have considered considered two state, one $\ce{Zn}$ as its elementary substance and second as $\mu_{\ce{Zn}}=E_{\ce{ZnO}}-\mu_{\ce{O}}$ where $\mu_{\ce{O}}$ is energy of oxygen as elementary substance. For stability of any structure you can do mechanical(elastic constants) and dynamic stability(phonon) calculations. Based on formation energy one can say that if it is negative, such doping are more favorable.