Yes. Nationality does not prevent you from inheriting in Spain, whether under a will or under succession law.
Steps for non-resident foreign heirs:
- Power of attorney: grant a special power for that inheritance to a representative in Spain, by video call with a Spanish notary or at the consulate, so that they can handle it on your behalf
- Documents from your country: you may need apostilled documents (marriage or birth certificate, for example) depending on your relationship to the deceased
- Tax: as a non-resident heir, you pay tax in Spain on assets located in Spain