Preheat your oven to 375°F (190°C) and grease a square baking dish thoroughly to prevent sticking.
Make the roux by melting butter in a saucepan and whisking in the flour for 1 minute until lightly golden and fragrant.
Slowly whisk in the milk, simmering over medium heat until the sauce is thick enough to coat the back of a spoon.
Stir in 2 cups of cheese, nutmeg, salt, and pepper until the cheese is melted and you have a glossy Mornay sauce.
Combine the cooked pasta, ham cubes, and cheese sauce in a large bowl, tossing until every tube is filled and coated.
Transfer to the baking dish, pressing down slightly to ensure a dense structure, and top with the remaining cup of cheese.
Bake for 20 minutes, then broil for 2-3 minutes until the top is bubbly and deeply browned.
Let it rest for at least 10 minutes before slicing to ensure perfect, clean layers and that signature gratin shape.