Prepare the fried onion topping. Preheat the oven to 475F. Slice the onion thinly. Place onion in a small bowl. Add the remaining fried onion topping ingredients and toss to combine. Use a little milk if necessary for it to just stick together.
Spread the dredged onion out on a silicone baking mat lined baking sheet. Bake until just golden brown, approximately 20-30 minutes. Toss the onions at least once during baking to toast all sides. When done, set aside.
While the onions are cooking, prepare the green beans. Bring a large pot of water to a boil over high heat. Trim the beans and cut into 1-2 inch long pieces. Add the green beans to the boiling water and cook until just blanched, 5 minutes. Remove the beans from the hot water. Immediately drain the beans and put them in a large bowl of ice water to stop the cooking process. Set aside.
Make the pesto if not already done.
Make the sauce. In a large skillet, melt the butter over medium high heat. Add the mushrooms, salt, and black pepper. Stir to combine and cook until the onions just start to release some liquid, approximately 3-5 minutes.
Add the garlic cloves. Stir and cook another 1 minute until fragrant.
Sprinkle the flour on top of the mushrooms and stir to combine. Cook for one minute to slightly toast the flour.
Add the vegetable stock and cook for one minute. Reduce the heat to medium low and add the milk. Cook until the sauce has slightly thickened, approximately 5 minutes.
Remove the sauce from the heat and add 1/2 cup of freshly grated Parmesan cheese (reserve the remaining 1/4 cup). Stir to combine until the cheese is melted.
Add the green beans and basil pesto to the sauce and stir. Season the sauce to taste as needed with additional pesto, Parmesan cheese, salt, or pepper.
When ready to serve, heat oven to 400F. Place the green bean mixture in a casserole dish. Top with the fried onions and remaining 1/4 cup freshly grated Parmesan cheese. Bake until bubbling, approximately 10-15 minutes. Serve immediately.