In a large skillet, melt butter over medium heat and sauté onions for 25 minutes until deep golden brown; set aside to cool.
Preheat oven to 375 degrees Fahrenheit (190 degrees Celsius).
In a small bowl, combine panko breadcrumbs and milk, allowing them to soak for 5 minutes.
In a large mixing bowl, combine ground beef, half of the caramelized onions, the soaked breadcrumbs, egg, Worcestershire sauce, thyme, garlic, salt, and pepper.
On a parchment-lined baking sheet, form half of the meat mixture into a 9x5 inch rectangle.
Place the shredded Gruyere cheese in the center of the meat, leaving a 1-inch border around the edges.
Top with the remaining meat mixture and pinch the edges firmly to seal the cheese inside.
In a small bowl, whisk together the ketchup, balsamic vinegar, and the remaining caramelized onions.
Brush half of the glaze over the meatloaf and bake for 45 minutes.
Apply the remaining glaze and bake for an additional 15-20 minutes until the internal temperature reaches 160 degrees Fahrenheit.
Let the meatloaf rest for 10 minutes before slicing to ensure the cheese center sets.