It means someone is feeling defeated, ashamed, or humiliated, and they are trying to avoid attracting attention or confrontation.
The image is of a dog or other animal who has been scolded or punished and is trying to hide from further punishment.
Here are some examples of how to use the idiom:
* "After losing the election, the candidate left the stage with his tail between his legs."
* "The bully walked away with his tail between his legs after the victim stood up to him."
* "The company was forced to apologize to its customers and admitted its mistake with its tail between its legs."
The idiom "with his tail flying in the sky" doesn't exist.