Preheat the oven to 375 degrees. Thinly slice two of the onions. Melt the butter in a skillet over medium heat and cook the sliced onions until golden and soft, about 15 minutes. Set aside half of the cooked onions for the gravy.
Chop the remaining onion into small pieces. In a large bowl combine the ground beef, chopped onion, breadcrumbs, egg, thyme, garlic, salt, and pepper. Mix until just combined, then stir in the reserved half of the caramelized onions.
Shape the mixture into a loaf. Lay the bacon slices across the top and sides, tucking the ends underneath. Place the loaf on a rimmed baking sheet and bake for 50 to 60 minutes until the internal temperature reaches 160 degrees.
While the meatloaf bakes, return the skillet with the remaining caramelized onions to medium heat. Sprinkle in the flour and stir for one minute. Slowly whisk in the beef broth and simmer until the gravy thickens, about 5 minutes. Season with salt and pepper.
Let the meatloaf rest for 10 minutes before slicing. Serve with the warm onion gravy spooned over each portion.