When the last defender is removed, the Gym will turn grey, and only Trainers from the same team as yours can claim it for a certain amount of time. To add your Pokémon to the defending team, tap on the Gym, then tap on the icon with a plus sign in the bottom-right corner of your screen. From there, select a Pokémon to defend the Gym and it will appear in the defending lineup.