@yon2655 below is my view on this ---
First the situation --- Person A uses somebody else's SSN, is without papers and works in the USA ---- SSN is SSN#1. Subsequently A receives work permit and gets a proper SSN called SSN#2.
IRS does not care whether the earner is legal or illegal with or without work permit. All they care about is that each earner has paid the proper taxes ( including Social Security and Medicare ). Thus the easiest solution is for this person A to have two W-2 issued --- one with the original (fake? ) SSN#1 and a second with new issued SSN#2. This does mean help from the employer and also means that the FICA contributions would go to two SSNs ( SSN#1 and SSN#2 ) and the Person A when retired would only get the benefits based on payments to SSN#2. Everything depends on how the W-2 is issued.
Does this help ?
You could ask your employer for a 'Corrected W-2' that shows only the amount that you earned with your correct SSN.
You can then file your return inTurboTax with this W-2.
You can't use the W-2 with the incorrect SSN to file your taxes.
Click this link for instructions on How to Enter a Corrected W-2.
**Mark the post that answers your question by clicking on "Mark as Best Answer"
@yon2655 , I recognize the following advice from @MarilynG1 would be the right way to go forward. However, I would suspect that the employer ( especially if small ) would balk at having to issue another W-2 with the correct SSN -- he probably have no problem doing a 2021 with the new SSN ( and changing name at the same time). If that is the case, then suggest use the W-2 issued to file the return this year ( i.e. with the old SSN, old name etc. ). This does mean that any refunds may be issued to a different name and your bank may or may not cash that -- unless of course the bank account is with the old name and the old SSN. This also means for the year 2021 you really have to start everything with the "new " name and the new SSN.
The IRS does not care if you are legal to work or not, and they won't inform on you to ICE or anyone else, but you can still get in trouble if you don't report your honest wages and pay the correct income tax.
In the situation where you have a W-2 that represents your wages, but reported in the name and SSN of another person, and assuming the employer can't or won't make the correction, I would suggest using form 4852, "substitute W-2" for a missing W-2. You can get turbotax to make this form by entering your wages and other information under your correct SSN in the program, then check the box for special circumstances for "I did not get a W-2."
I say this because, when the IRS comes looking for "Mr. Smith" who failed to report this W-2, Mr. Smith will declare themselves to be a victim of identity theft and never worked for your employer. You never really got an SSN under your own name, so in a sense, your W-2 is still "missing."
I am assuming here that you no longer work for employer #1 who issued the W-2 under the wrong name, and any job you now have is under your right name and SSN. If the incorrect W-2 was from a job you still have, then the employer really needs to correct things. I would have to think further about it.