Peel and thinly slice onion. In a 10- to 12-inch frying pan, combine onion, butter, sugar. Stir often over medium-high heat until onion is limp and lightly browned, 12 to 15 minutes. Add flour and mix well. Remove pan from heat; stir in milk and beef broth. Stir over high heat until boiling; continue stirring until liquid is almost evaporated and mixture doesn't flow when scraped from pan bottom, 4 to 5 minutes. Remove from heat. Add gruyère cheese and parmesan cheese; stir until melted. Season to taste with salt and pepper. Use hot. If making up to 1 day ahead, let cool, then cover and chill; reheat in a microwave-safe bowl in a microwave oven at full power (100%) for about 1 minute.