I think the (negative) answer follows from Vims' paper Totally Geodesic Maps.

Indeed, assume for simplicity that the manifolds $P$ and $B$ are compact. Vilms proves that any totally geodesic map factors as a totally geodesic Riemannian submersion followed by an immersion. Since $G$ is connected, the image of any fiber under the submersion is a point, so the original totally geodesic map descends to an immersion of $B$ into itself, which must be a diffeomorphism as $B$ is compact. Vilms also proves if $P$ is complete (e.g. compact), then a Riemannian submersion is totally geodesic iff the fibers are totally geodesic and the horisontal distribution is integrable.

So essentially you are asking whether any principal $G$-bundle can be given a Riemannian submersion metric with totally geodesic fibers and integrable horisontal distribution. The former can be arranged, as Vilms proved in the same paper. Satisfying both things seems impossible. Indeed, if the horisontal distribution is integrable, then the $A$-tensor vanishes. Since the fibers are totally geodesic, the $T$-tensor vanishes. Thus the submersion is locally isometric to a product. Assuming further that $B$ is
simply-connected, we conclude that $P$ must be isometric to the product $G\times B$, and in particular, the principal bundle is trivial. To summarise:

If $B$ is a closed simply-connected manifold, and $P$ is a nontrivial principal bundle over $B$ with compact connected structure group, then the bundle projection cannot be totally geodesic.

The simplest example when this happens is the Hopf fibration $S^3\to S^2$.