First ask your 401(k) administrator to return to you the excess (together with any earnings/losses) before April 15, 2024.
Report excess salary deferrals (excess 401k contributions) returned to you after the end of the tax year but by April 15th of the following tax year on your 1040 as Wages. Don't create your own 1099-R for this situation.
Page 11 of IRS Pub 525 under Excess deferrals (the IRS term for 401K contribution is deferral) tells us:
If your deferrals exceed the limit, you must notify your plan by the date required by the plan. If the plan permits, the excess amount will be distributed to you. If you participate in more than one plan, you can have the excess paid out of any of the plans that permit these distributions. You must notify each plan by the date required by that plan of the amount to be paid from that particular plan. The plan must then pay you the amount of the excess, along with any income earned on that amount, by April 15 of the following year. You must include the excess deferral in your income for the year of the deferral. File Form 1040 or 1040-SR to add the excess deferral amount to earned income on line 1h.
What you earned will be covered by a 1099-R for the following tax year and will be entered as a normal 1099-R on your next year's return. If you have a loss, that loss isn't deductible.
Below is how to do this in TurboTax Online: