Melt butter and olive oil in a large pot or Dutch oven over medium heat.
Add sliced onions, sugar, salt, and pepper. Cook, stirring occasionally, for 30-40 minutes, or until the onions are deeply caramelized and golden brown.
Pour in beef broth and sherry (if using). Bring to a simmer and cook for 15-20 minutes to allow the flavors to meld.
Preheat broiler. Place French bread slices on a baking sheet and broil for 1-2 minutes per side, or until lightly toasted.
Ladle soup into oven-safe bowls. Top each bowl with a slice of toasted French bread and sprinkle generously with grated Gruyere cheese.
Broil for 2-3 minutes, or until the cheese is melted and bubbly. Serve immediately.