I don't think there is any law against converting a mag to fit a different gun -- I've read through the Federal regs several times. There IS law that says you can't MODIFY the magazine to exceed the ban limit (10 rounds) if the mag was made after the imposition of the ban.
To make most 9mm mags work with a .40 would probably require some bending of feed lips, at a minimum, and that is MODIFICATION. Some 9mm mags might work without modification.