No, you cannot contribute to an HSA when you are on Medicare, the account is intended for high deductible health plan participants. You can use the funds that were contributed before you were on Medicare.
If you enroll in Social Security you will be automatically enrolled in Medicare Part A, which will disqualify you from contributing to an HSA. You can delay enrollment in Medicare Part A only if you delay taking Social Security. You can delay taking Social Security up until age 70 and one half years old.