Yes, placing your Pokémon in gyms and successfully defending them can earn you Stardust. The longer your Pokémon remains in the gym, the more Stardust you will accumulate.