You can't open and continue making contributions to an HSA if you have enrolled in Medicare Part A or Part B. If you have established an HSA prior to doing that, though, you can continue to make distributions for your approved medical expenses.
If you do enroll in Part A or Part B, you will lose eligibility to contribute in the first day in the month that you turn 65. Please note that when you enroll in Part A, the coverage is retroactive for 6 months, meaning that you would not be eligible to make HSA contributions for that 6 month period.
Source: IRS Notice 2004-2 Q&A 27