"Call Legal if the police officer in Nicaragua is threatening to throw you in jail without arrest until you give him cash" is a reasonably sure way to put yourself at further risk/in grave peril.
However, if you need to pay a "facilitation fee" to exit the country (called routine govt action) that is not about securing business or getting a competitive advantage such as a customs waiver, then paying the fee may be permitted (for a number of reasons).
What I think US folks don't realize is some dept's overseas basically pay their staff through these unofficial fees, they set some rates for service, but nothing goes through treasury and no enabling legislation exists. But they also don't get money from their treasury to operate (or its stolen by folks above them) so that's how they keep operating.
In Russia prior to USSR, facilitation fees is how all officials earned money, that was the official policy. That's only 100 years ago that is was not even considered corruption / bribery. Obviously that disease is still festering in Russia and the country as a whole is paying a grave toll for it.
Lastly, do keep in mind that as a local you can probably tell is a payment can be declined withoit repercussions, but as a foreigner you don't really know.