Place a steamer insert into a saucepan and fill with water to just below the bottom of the steamer. Bring water to a boil. Add green beans, cover, and steam until slightly tender, about 5 minutes.
Stir 2 tablespoons butter, flour, onion, sugar, and salt together in a saucepan over medium heat; gradually stir in sour cream. Cook and stir mixture until hot, thickened, and smooth, about 10 minutes. Add steamed green beans to the cream mixture. Pour green bean-cream mixture into a 2-quart casserole dish; sprinkle with Swiss cheese.
Mix corn flakes and 2 tablespoons butter in a bowl until well coated; sprinkle over Swiss cheese layer.
Bake in the preheated oven until cheese is bubbling and topping is browned, about 20 minutes.