I've been trying to solve this problem for years. A good solution does not exist so far. I've carried on the hip in a leather holster under the pack waist belt. It actually worked decent with a not-too-heavy pack and assuming you didn't need super quick access to it. Accessing it required the pack belt be undone. Attaching the holster to the pack belt works really well and gives quick access, but there's no concealment and if you take your pack off, the gun goes with it. When I carry like this, I pack a second, paddle style holster in my pack so when I get to camp I can clip on the paddle holster and still be armed. One major caveat of pack belt type of carry is when the pack is put on/off the gun and holster swing all around muzzle sweeping everything and everyone until the belt is clipped tight. Obviously you can take the pistol out before the on/off event; however, holstering/unholstering is one the most dangerous things you can do with a loaded gun.

Chest rigs / bino harnesses work pretty well. Some even come with a pouch designed for a pistol. They often don't accommodate a full size gun and if they do, the chest rig is ostentatiously obese. I like the chest rig during hunting season a lot, but for overnight summer hiking trips, it's cumbersome and hot and looks tactical mall cop.

Last option which worked pretty well this year during hunting season is a cowboy/Han Solo dedicated gun belt. Use your regular holster and a second belt - not the belt holding up your pants. The second belt and holster are worn cowboy style so the gun is dropped below the hip. The hip belt of the pack rides on your waist above the gun and holster. I found this works with some packs and not others...depends on the pack hip belt design. When this works, it works really well.

It's all a compromise between accessibility, concealment, gun size, and comfort.