According to the fatawa of Fatwa of Dr. Main Khalid Al-Qudah, a Member of the Fatwa Committee of the Assembly of Muslim Jurists in America:
Borrowing from your 401(K) is not a sin, because as you said, you pay interest to yourself, which is in reality, not an interest while borrowing from a traditional bank is the most explicit example of riba.
Borrowing from one’s 401(K) to get money is not defined as a loan contract from an Islamic perspective, although it looks so outwardly. It is just a legal way to circumvent taxing that amount, as you know. With this in mind, paying the so-called (interest) to withdraw the savings money is allowed.