Hot-dip Al–Si alloy coatings with excellent resistance to corrosion and high-temperature oxidation have emerged as promising lightweight substitutes for conventional corrosion-resistant coatings. The introduction of Mg can be an effective strategy for enhancing the sacrificial protection capability of Al–Si coatings. In this study, the effects of Mg addition on the morphology, electrochemical behavior, and mechanical properties of Al–Si coatings were investigated, along with the Mg-content optimization of the coating layer. Adding Mg promoted the formation of finely distributed eutectic intermetallic phases, such as Al/Mg2Si and the primary Mg2Si phase. Notably, the Mg2Si phase coarsened significantly when ≥15 wt.% of Mg was added. In addition, an Al3Mg2 intermetallic compound was observed in coating layers containing >20 wt.% of Mg, reducing the adhesion of the coating layers. Samples containing 5–10 wt.% of Mg exhibited excellent corrosion resistance (owing to a uniform distribution of the fine eutectic Al/Mg2Si phase and the formation of stable corrosion products), whereas those containing 20 wt.% of Mg exhibited unremarkable corrosion resistance (owing to the formation of an Al3Mg2 phase that is susceptible to intergranular corrosion).