Preheat the oven to 375°F and lightly grease a loaf pan.
Melt the butter in a skillet over medium heat. Add the sliced mushrooms and diced onion, then cook until the vegetables soften and the liquid evaporates, about 6 to 8 minutes. Set the mixture aside to cool slightly.
In a mixing bowl, combine the ground beef, breadcrumbs, egg, garlic powder, salt, and black pepper. Mix with your hands until the ingredients are evenly distributed.
Place half the meat mixture into the prepared loaf pan and press it into an even layer. Spoon the cooked mushroom and onion mixture down the center, leaving a small border around the edges.
Cover the filling with the remaining meat mixture and seal the edges so the stuffing stays inside. Spread the ketchup evenly over the top.
Bake for 50 to 55 minutes until the internal temperature reaches 160°F. Let the meatloaf rest for 5 minutes before slicing.