Melt the butter in a large skillet over medium heat. Add the sliced onions and cook, stirring often, until they turn deep golden brown and soft, about 25 minutes. Stir in the garlic and cook for one more minute, then remove from heat.
Heat the oven to 375 degrees and lightly grease a loaf pan. In a large bowl, combine the ground beef, breadcrumbs, egg, beef broth, thyme, salt, and black pepper.
Set aside one cup of the caramelized onions. Mix the remaining onions into the meat mixture until evenly distributed. Press the mixture into the prepared loaf pan.
Bake for 45 minutes. Remove the pan from the oven, spread the reserved caramelized onions over the top, and sprinkle with the Gruyere cheese. Return to the oven for 10 more minutes until the cheese melts.
Let the meatloaf rest for 10 minutes. Slice and serve each portion with a slice of crusty bread on the side.