We investigate the impact of various dopants (Na, Ag, Cd, Zn, Al, Ga, In, Tl, Ge, and Sn) on the electronic structure of Mg2Si by first principles calculations using a hybrid functional that does not need a band gap correction. We find that for Na and Ge in Mg2Si, the impurity-induced states do not affect the density of states at both edges of the valence band and the conduction band. Ag- and Sn affect slightly the density of states at the valence band edge, while Cd and Zn affect slightly the density of state at the conduction band edge. Al and In could modify significantly the density of states at the conduction band edge. Ga introduces states just at the bottom of the conduction band. Tl introduces states in the band gap. This study provides useful information on optimizing the thermoelectric efficiency of Mg2Si.