As an example, let's say I put a Pokémon in a gym, say, Tuesday at noon, and it remains in the gym until Thursday at noon. Assuming I have nothing else in gyms collecting coins, would I get coins for this on Tuesday (where the Pokémon wasn't returned to me), or Wednesday (where it was neither placed in the gym nor returned); or would I only get coins for Thursday?
No, you only get coins when the Pokémon is returned to you and you are capped at 50 coins per day. Thus, you can never get more than 50 coins from any Pokémon that is returned to you.
For instance, I left an Arcanine in a gym for nearly 3 days. When it was returned to me, I received 50 coins. I did not receive any coins from Arcanine the two previous days.