Addressing bone tissue defects is a critical challenge in clinical practice, necessitating the development of biomaterials that can orchestrate both immune modulation and tissue regeneration. This study introduces and assesses the immunomodulatory effects and bone repair capabilities of a novel 3D-printed scaffold composed of gelatin methacryloyl (GelMA), nanohydroxyapatite, and melanin nanoparticles (GHM). The GHM scaffolds, characterized by their optimal porosity, viscosity, and mechanical strength, have been shown to effectively direct macrophage polarization from the initial M0 state to the anti-inflammatory M2 phenotype. Concurrently, osteogenic precursor cell lines MC3T3 are stimulated to differentiate into osteoblasts under the influence of macrophage-conditioned medium. In vivo studies using normal mice cranial defect models and macrophage-depleted cranial defect models have demonstrated that GHM scaffolds can attract macrophages to the implantation site, promote their M2 polarization, and consequently, significantly enhance bone formation and effectively treat cranial defects in mice. RNA-sequencing analysis has revealed elevated expression of the Leukemia inhibitory factor (Lif) gene in macrophages treated with GHM, implicating its role in regulating macrophage polarization. These findings underscore the potential of GHM scaffolds as an immunomodulatory biomaterial for bone tissue engineering applications.