Preheat your oven to 400 degrees Fahrenheit and lightly grease a 9x13-inch baking dish. Bring a large pot of salted water to a boil, add the green beans, and cook for 5 minutes until bright green and crisp-tender, then drain and transfer them to the prepared baking dish.
Heat the olive oil in a large skillet over medium-high heat, add the mushrooms, and cook for 6-8 minutes until they have released their liquid and turned golden brown, then season with 1/4 teaspoon of the salt and 1/4 teaspoon of the pepper before scattering them over the green beans.
Melt the butter in the same skillet over medium heat, add the chopped onion, and cook for 4-5 minutes until softened and translucent, then stir in the garlic and cook for 1 more minute until fragrant.
Whisk the gluten-free flour into the onion mixture and cook for 1 minute to form a paste, then slowly pour in the milk while continuously whisking to create a smooth, thick base without any lumps.
Pour in the vegetable broth, heavy cream, remaining salt, pepper, and gluten-free soy sauce, bring the sauce to a simmer, and cook for 3-5 minutes while stirring until it has thickened enough to coat the back of a spoon.
Pour the creamy sauce evenly over the green beans and mushrooms in the baking dish, then stir gently with a spoon to ensure everything is well coated.
Bake the casserole uncovered for 20 minutes, then remove it from the oven, top evenly with the gluten-free fried onions, and return it to the oven for 5 more minutes until the topping is golden and the casserole is bubbling.
Let the casserole rest on a wire rack for 10 minutes before serving to allow the sauce to set slightly for easier serving.