In a medium saucepan, melt 2 tablespoons butter over medium-high heat; add onions stir for about a minute or until foaming. Add flour, continue cooking, stirring frequently for about 1 to 2 minutes or until bubbling. Remove saucepan from heat. Then gently add milk, whisking constantly, until mixture is smooth, add bay leaf and thyme. Return saucepan to heat. Keep stirring with a wooden spoon, for 8 to 10 minutes or until sauce comes to the boil, thickens and coats the back of a wooden spoon. Remove from heat. Stir in Parmesan, salt and nutmeg. Transfer to a bowl to cool.
For the Bread
Heat a large cast iron skillet or grill pan until hot, oil with half of the butter then place bread on it and brown each side for about 2 minutes
Transfer to a baking sheet and repeat with the remaining slices of bread sandwiches using the remaining butter.
Top each sandwich with 2 to 3 slices of ham. Combine half of the Gruyere cheese with the béchamel sauce. Adjust for seasoning. Spread a small amount of the Gruyere sauce on top of the ham and top each with another slice of bread.
Spread the remaining béchamel on top of the sandwiches and top with the other half of the Gruyere cheese.
Broil until cheese sauce is bubbling and evenly browned, about 3–4 minutes.
For the Egg
Meanwhile, if using a nonstick skillet wipe any crumbs from the pan, then add oil. Heat on medium, add eggs, season with salt and pepper, and cook until whites are cooked but yolks are still runny, about 3 minutes.
If you prefer a more cooked egg cook a little bit longer till desired consistency has been reached. Place an egg on top of each sandwich, and serve hot.
Please keep in mind that nutritional information is a rough estimate and can vary greatly based on products used.