You became ineligible to contribute to an HSA for the month you became covered by Medicare and beyond. If you made a contribution for 2021 based on the last-month rule, becoming covered by Medicare means that you have has a lapse in the coverage required to satisfy the testing period required by the last month rule. With a lapse in coverage, any amounts contributed to the HSA for 2021 in excess of what you were eligible to contribute without the last-month rule are subject to a 10% excise tax determined on Part III of your 2022 Form 8889.
Also, any amount contributed to the HSA for 2022 in excess of the annual limit prorated by the number of months in 2022 you were HSA eligible is an excess contribution for 2022.