4 tablespoons salted butter, softened, divided
1 ½ tablespoons all-purpose flour
1 cup milk
2 ounces shredded Gruyère cheese
¼ teaspoon salt, or to taste
¼ teaspoon ground black pepper, or to taste
⅛ teaspoon ground nutmeg
4 slices white bread, lightly toasted
2 teaspoons Dijon mustard
2 thin slices Black Forest ham
2 large eggs
1 tablespoon water
1 teaspoon chopped fresh dill, or to taste (Optional)
Set an oven rack about 6 inches from the heat source and preheat the oven's broiler.
Melt 1 1/2 tablespoons butter in a saucepan over medium-low heat. Whisk in flour and stir until slightly brown, about 3 minutes. Whisk in milk; bring to a boil, stirring constantly. Once boiling, reduce heat immediately and simmer for 5 minutes. Add 1/2 of the Gruyère cheese, salt, pepper, and nutmeg; heat until cheese is melted, about 2 minutes. Remove from the heat and set aside.
Spread about 1 teaspoon butter on 2 pieces of bread. Spread 1 tablespoon cheese sauce on top and layer each with a ham slice. Spread 1 teaspoon butter on the remaining 2 pieces of bread, then spread Dijon mustard on top and sprinkle with remaining Gruyère. Transfer all 4 pieces to a baking sheet.
Broil in the preheated oven until cheese is almost melted, 2 to 3 minutes. Remove from the oven, place toast slices together to make 2 sandwiches and pour remaining cheese sauce on top of each sandwich. Return to the broiler until sauce starts to brown, about 2 minutes.
While the sandwiches are broiling, heat remaining butter in a nonstick skillet over medium-high heat. Crack 2 eggs into the skillet, keeping them completely separate from one another. Season with salt and pepper. Add water, cover, and baste until whites are set but yolks are still runny, about 2 minutes.
Top each sandwich with an egg and sprinkle with dill, if using. Serve immediately.