Magnusson Moss Warranty Act covers you under the MANUFACTURER'S warranty.
If a warranty agreement states otherwise, the Act is rendered void.
As an example, a Nissan GT-R warranty agreement states a list of restrictions that are applied to the vehicle in order to sustain warranty. If you violate any of the points, your car does not have to be services under the warranty, and you dealership can freely charge you (owner).
In the situation that you are describing, dealership is acting on their own accord, and their warranty is not affected by the Act as the MM Act covers manufacturer's warranty only, AND the warranty agreement states that "ANY alteration will void the extended warranty".
it IS legal.
As far as dealerships telling people with normal manufacturer's warranty that a mod will void it, it is a lie. Although, many people confuse "void" and "refuse to service" terms. The latter is the right of a dealership; they can refuse to honor the warranty under suspicion of damages being caused by an aftermarket product.
In that situation, you have three routes - either argue, and force them prove that the damage was caused by the mod, take your vehicle to a different service, pay the requested $$.
I've been down this road a few times..