Transportation costs (mileage) is something that is a qualified medical expense for the HSA. However, your HSA can only be used to pay for the medical expenses of certain people. According to IRS Publication 969,
Qualified medical expenses are those incurred by the following persons.
You and your spouse.
All dependents you claim on your tax return.
Any person you could have claimed as a dependent on your return except that:
a. The person filed a joint return;
b. The person had gross income of $4,300 or more; or
c. You, or your spouse if filing jointly, could be claimed as a dependent on someone else’s 2020 return.
You mentioned that your elderly relative is not your dependent, so the answer to your question is probably no, you cannot take an HSA distribution for these miles, unless your elderly relative meets the criteria in point #3 above.