I’m not great at physics and have no knowledge of aeronautics, so this whole chain of reasoning might be wrong.
A plane stays in the air because air is moving over the wings, which generates lift. However, that air is moving because the engine is moving the plane forward. There is no other source of energy. Therefore, some of the engine’s energy is going into keeping the plane in the air, and some is going into accelerating it forwards, or keeping it at the same speed (fighting air resistance).
Therefore, if the plane points straight up, the engine should be able to support it hovering in the air. If it didn’t have enough power to fight gravity when pointing straight up, it wouldn’t have enough power to fight gravity when moving horizontally, either.
(Okay, some older engines only worked in certain orientations, but I don’t think that’s a problem for jet aircraft, or any aircraft built after WWII.)
So why can only certain planes fly vertically?
In military jets that can fly vertically, it’s because the engineers prioritize performance and capability over efficiency. Passenger planes prioritize efficiency over acrobatic ability.