Preheat the oven to 375 F. Butter a shallow 3-quart casserole.
Melt 3 tablespoons of the butter in a medium saucepan over medium heat. Sprinkle in the flour, season with salt and pepper, and whisk until the mixture is smoothly blended and starts to turn a light golden color. Gradually add the milk, whisking constantly. Continue to whisk often until the mixture just comes to a simmer, then whisk frequently for another 4 minutes, until the sauce has thickened. Adjust the heat so the mixture stays at a simmer.
Meanwhile, in a large skillet with a lid, heat 2 more tablespoons of butter over medium heat until melted. Add the onions and mushrooms and sauté for about 8 minutes until the vegetables are brown and any liquid that gets released evaporates. Season with salt and pepper. Stir the mushroom mixture into the white sauce.
Return the skillet to medium-high heat and add the broccoli and the broth. Bring the mixture to a simmer, then cover the pan and steam the broccoli for 4 minutes until almost tender.
Pour the white sauce into the pan with the broccoli and remaining broth (there should be about 1 1/2 cups left in the pan) and stir to combine. Add the sour cream and the cheese and stir to blend well. Transfer the mixture to the prepared baking dish and spread it out evenly.
Bake for 30 minutes until bubbly and golden brown on top. Serve hot.
Notes
One variation on this casserole is to add 1 1/2 cups of cooked rice along with the white sauce, which will give the casserole a bit more heft and density. If you want to make this into a chicken and broccoli casserole, you can add 2 cups of shredded or diced cooked chicken when you add the white sauce into the pan with the broccoli. Obviously, this is no longer a vegetarian casserole once you add the chicken.