How do you train your Pokémon in Pokémon GO when all gyms you can visit are too high level?
Solution 1:
While a bit counter-intuitive, training at a gym is beneficial for the gym, rather than your Pokémon. The "training" you're thinking of is "powering up" in this game.
Training at a gym will raise the prestige of the gym, which levels the gym itself up and allows more Pokémon to be placed inside of it to defend it from rival teams.
Powering up your Pokémon will increase their level by 0.5 (to an absolute maximum of 40, or by 1 up to 80, depending on who you ask), which will increase its stats. As noted in the comments, the maximum level of your Pokémon is capped by your current trainer level. For each time your trainer levels up, you are able to power your Pokémon up two additional times. To strengthen your Pokémon, you need to power them up with the appropriate candy and stardust.
Solution 2:
You don't train Pokémon in gyms. Gyms are there to get gold each day to buy stuff in the market.
To train Pokémon you need to go in the said Pokémon page and select power up (which uses both dusts and candies).
This way your Pokémon's CP will rises meaning it's more effective in battle. Another way to make the CP rise is by evolving them. This will require a lot of candies but, depending on the species of Pokémon you have, can go up to doubling (and even more) its CP.
From there on you should read about CP, stats and battling to learn more about the game mechanics for gym battles if you are still interested in said subject.