If your phone still retains a valid baseband version but shows an "Invalid IMEI" error message, you can try writing the data directly via the internal engineering matrix: