Aren't the World Nobles immune to any form of justice? Why does Doflamingo have a bounty?
It appears that only a couple people within the Marines even know about Doflamingo's status. Or who knows, maybe the Marines were ordered to give him a bounty anyway for whatever reason he has for being a pirate to help mask his identity…
Either way, this has been ongoing for a very long time as Doflamingo has been a pirate (or pretending to be one, dunno) for about half of his life.