From personal experience: I don't think there's a cooldown.
I had beaten a gym some days ago and the game was pretty laggy.
When I was finally able to place a pokemon, the gym was already another color.
No official information though, sorry.
EDIT:
The game updated since I posted this answer.
The answer is no longer correct!
New answer is: It is not possible to steal someone's gym now, battle winners have priority.
gaming.stackexchange.com/users/154245/Dwarz
Yes.
Anyone can place a Pokemon in an open gym as soon as prestige drops to 0, there is no cooldown after battles.
I was just in an area where the gym was held by my team, and it went white.
I immediately put my own Pokemon in the gym, and recaptured it.
gaming.stackexchange.com/users/155230/Ben Murphy
I think it's a free for all.
I just won my first gym battle and by the time I healed my main Pokemon and put him in the gym it briefly turned yellow then gave me an error bar at the top and it switched to red.
The occupier was low level but I had to reboot as the gym battle glitch happened.
By the time I got back in someone else from yellow team captured it
and I was able to add my own Pokemon and take gym lead.
It seems like taking control of a gym is extremely chaotic and unpredictable.
I noticed that a lot of the gyms around me with 1300cp Pokemon were going down and being replaced by teams with less than 500 Cp.
I understand why now.
Once it's open
the vultures come
out.i think they need to rethink this system.
gaming.stackexchange.com/users/155302/Chucknastical
The game had an update a while ago, now there is a cooldown where only the victor can place a pokemon in the gym.
gaming.stackexchange.com/users/154245/Dwarz
I have literally just stolen a gym.
I was training my gym to put another Pokemon in it when some kid turned up and kept beating my gym and taking over it.
While we was going back and forth fighting for control, I noticed the gym change from red (my colour) to white
so I clicked it and placed a Pokemon there.
I did feel tight when the kid said he just beat the gym but it wouldn't let him put a Pokemon there.
But hey, "I wanna be the very best!"
gaming.stackexchange.com/users/157628/Lee Yerex
When I defeat a gym and get its prestige level to zero, is there a cool-down where only I, the conqueror, can place a Pokémon in it?  I wonder if someone could just wait at a public place for the moment when the gym becomes blank.  However, if such a cool-down exists, does anybody know how long it is?
Can someone "steal" my Gym?
gaming.stackexchange.com
<pokemon-go>
gaming.stackexchange.com/questions/274618
gaming.stackexchange.com/users/125433/h0ch5tr4355
Anyone used to be able to place a Pokemon in an open gym as soon as prestige drops to 0, there is no cooldown after battles.  The game had an update a while ago, now there is a cooldown where only the victor can place a pokemon in the gym. Whereas in the past it was possible to steal someone's gym when the prestige dropped to 0, now this has been fixed and there is a cooldown.
Users suggest it is free and some one could potentially take it as soon as the prestige is 0. Newer information suggests this has been patched.