You can convert the result invalid WIF private key into the correct format by base58-decoding it into HEX, remove the checksum and network bytes,
and you got the private key.
Then covert that into WIF by doing vice-versa but this time, use "0x80" instead of '0x0A' in front.
This page automates all of that, displays an example and the steps: https://gobittest.appspot.com/PrivateKey,
Just paste the N, M or L WIF prvkey to the first text box, hit "send", and the result will be displayed under "Private key to wallet import format" at step #7.
But it's not available offline, if you want a secure method, find a script or something.