At least in Australia, I'd be surprised if more than a single digit percentage of the population would be able to tell if the (US) currency someone presents is real vs pretend/monopoly money.
They'd most likely think the person is trying to scam them.
The places where I've seen this mostly work was near borders, and it makes sense that you'd accept the neighbour currency there even if it is some overhead. If you can quickly hop over the border you're much less likely to exchange currency before than if you plan a full trip in a different country.
In most cases e.g. a French tourist would be fine taking euros, but a British tourist can take pounds and not pay to convert to dollars or euros first.
Kenya and Egypt are two examples.
I've seen Americans try to pay for taxi's in Thailand with USD, the drivers aren't interested, it's a hassle more than anything. In cambodia on the other hand, yes, they'll take it.
Depends entirely on how stable the local currency is, if it's reasonably stable and well managed then probably they won't be interested.
Or at least nicely told to go and exchange it for real money (local currency) somewhere, then come back and try again. :)
Here are a few cherry picked examples
https://www.reuters.com/world/americas/half-payments-caracas...
https://www.tripadvisor.com/ShowTopic-g293974-i368-k4798488-...
https://www.voanews.com/a/lebanon-leans-on-us-dollar-to-cope...
Mexico, Costa Rica, Panama, Nicaragua, Belize, and Colombia are places where I’ve done this personally and lots of Europeans were doing the same.
Friends and family in Costa Rica even advised that local currency wasn’t necessary and suggested bringing crisp bills from my bank.
But now that you point out "developing countries", that does seem more likely. :)
(In small towns it may be more difficult, but not impossible, specially if you are nice.)