01 - Preheat oven to 375°F. Grease a 2-quart baking dish with butter or cooking spray.
02 - Bring a large pot of salted water to boil. Add fresh green beans and cook for 4 minutes until just tender-crisp. Drain immediately and rinse under cold water to stop cooking. If using frozen beans, thaw completely and pat dry.
03 - Melt butter in a large skillet over medium heat. Add chopped onion and cook for 3 minutes until softened. Add sliced mushrooms and cook for 5 minutes until softened and liquid has evaporated. Stir in minced garlic and cook for 1 minute until fragrant.
04 - Sprinkle flour over the vegetable mixture, stirring constantly for 1 minute to cook out the raw flour taste. Gradually whisk in milk and broth, ensuring no lumps form. Bring to a simmer and cook for 2-3 minutes until the sauce thickens enough to coat the back of a spoon.
05 - Remove skillet from heat. Stir in sour cream, salt, black pepper, and nutmeg until fully incorporated. Add the prepared green beans and fold gently to coat evenly with the sauce.
06 - Pour the green bean mixture into the prepared baking dish, spreading it into an even layer.
07 - Bake uncovered for 20 minutes until the sauce is bubbly and the beans are heated through.
08 - Remove from oven and sprinkle crispy fried onions evenly over the top. Return to oven and bake for an additional 10 minutes until the onions are golden brown and the casserole is bubbling around the edges.
09 - Let the casserole rest for 5 minutes before serving to allow the sauce to set slightly for easier scooping.