Step-by-step explanation:
The electronic configuration of magnesium with Z = 12 is : 2, 8, 12
The electronic configuration of bromine with Z = 35 is : 2, 8, 18, 7
The Lewis structure is drawn in such a way that the octet of each atom is complete.
Thus, magnesium losses two electrons to bromine and 2 atoms of bromine accepts the electron.
Thus, the valence electrons are shown by dots in Lewis structure. The reaction is shown in image below.