Why would it be illegal? There are tons of people who are bowel incontinent that need diapers and end up involluntarilly using them in public. It's kinda rude to stink up a place deliberately, but if you have a secure diaper and lots of powder it's not too bad if you don't linger.
A trick I've tried both on myself and on littles I've cared for as a Mommy is to take an extra large dose of milk of magnesia about an hour before going out. The kind I use suggests 30-60 ml for a dose, I take around 90. It's relatively harmless if you do it infrequently (though read the warnings if you have health issues) and it's not a stimulant laxative, so it does not usually cause cramping.
What will happen is generally in around 2 hours after taking it your stomach will start rumbling and gurgling, in another hour you'll start to feel like you might need to go, and half an hour later or so you'll have no choice and have a nearly uncontrollable bowel movement. It'll be really liquidy and messy, so a dry-ish diaper is recommended to absorb the moisture.
The timing is unpredictable (part of why I like it), so those are averages. Sometimes it's more controllable than others, but usually I have very little control over it. The last time I did it, there was no rumbling or other warning ahead of time, I was in the grocery store and it just came out - just a little, and I managed to get through the self checkout and back to the car before the rest escaped, but it was pretty exciting.
Much better than the marshmallow trick or enemas because of the time delay and unpredictability - those happen so fast it doesn't really feel like I've lost control.