Melt butter in a large pot over medium heat. Add onions and sugar; cook until onions start to caramelize.
Meanwhile, in a small pan over medium-high heat, cook bacon until browned, approximately 5 minutes. Remove from heat, place onto a paper towel to cool.
Add gluten-free flour, sherry, beef stock and thyme to the onion mixture; bring to a simmer. Cook for 40 minutes. Season with sea salt and pepper to taste.
Transfer soup into six ovenproof soup bowls on a baking pan. Place crouton pieces over each bowl of soup. Lay a slice of cheese over the croutons in each bowl, and place under the broiler until cheese is melted and crusty brown around the edges. Top with bacon.