Roast the spaghetti squash at 400°F (200°C) for 45–60 minutes after cutting it in half, scooping out the seeds, drizzling with 2 tablespoons melted butter, and seasoning with salt and pepper.
Place cut-side down on a parchment-lined baking sheet until tender enough to pierce with a fork.
Let it cool slightly, then use a fork to shred the flesh into long spaghetti-like strands and set aside.
Melt the remaining 2 tablespoons butter in a large saucepan over medium heat. Sauté the chopped onion for 5–7 minutes until soft and translucent, then add minced garlic and cook for another minute.
Stir in the flour to make a roux, cooking for 1–2 minutes. Gradually whisk in the milk, a little at a time, until smooth.
Simmer for 5–7 minutes until slightly thickened, then season with salt, pepper, and nutmeg. Remove from heat and stir in ¾ cup Gruyere, ¾ cup cheddar, and ¼ cup Parmesan until smooth.
Gently fold in the shredded squash and transfer to a greased 9×13-inch baking dish.
Combine the remaining ¼ cup Gruyere, ¼ cup cheddar, ¼ cup Parmesan, and panko breadcrumbs, then sprinkle over the top. Bake for 20–25 minutes until the topping is golden and bubbly.
Let it rest for 5–10 minutes before serving and garnish with chopped parsley if desired.