As for the ECU side of things, there is NO black box that can prove you've flashed the car like a GTR does.
Here are two cases in which they might catch you on:
1) If you have left a non-stock ROM on there, they can tell. That one is just as simple as reading out specific memory locations.
2) Number of key cycles/engine turn overs. Every time you reflash the car, those numbers go to 0. 0 is pretty indicative that you've been flashing the car. However, if you put enough start #'s into it, or you state that you've pulled the battery cable to stop it draining (which also resets those counters), then you can prevent that obvious state from being used against you.
These are the two ways used by the dealership to validate if there has been ECU flashing or not.
Truthfully though, we have good relations with both Mazdaspeed North America and our local dealership, and they both said the same thing.