In the US, I have funds in my HSA account. If I were to close the account, transfer the funds into another bank account and move out of the US. Can I use the funds from this new account for non-medical purpose without incurring a 20% penalty ?
When you put money into the HSA, you didn't pay any tax on that amount. Now that you want to take money out, if you don't have any medical expenses to offset the amount you are withdrawing, you will need to pay tax, as well as the 20% penalty if you are under age 65.
You need to file a U.S. tax return in any year that you take money out of the HSA. On that tax return, you will declare how much you took out, and certify how much of that was used for medical expenses. Anything you take out that was not ultimately used for medical expenses will incur income tax and penalty.
If you can access the money in the HSA account from your new home country, you can keep the money in the HSA and then withdraw the money as you need it for medical expenses, even if the medical expenses are outside the U.S. You'll still need to file a tax return each year you take money out, but there won't be any taxes due, and you can keep doing this until you spend the last of your HSA money.