You can't. ISAs can only be provided by authorized ISA providers, and they are in the UK. (Official list here https://www.gov.uk/government/publications/list-of-authorised-isa-managers/isas-authorised-managers .) You will not find one in Spain, and can't you just magic up your own ISA wrapper around some Spanish assets.
I wouldn't be too worried about problems if you leave the country; it's a common enough situation. Official advice at https://www.gov.uk/individual-savings-accounts/if-you-move-abroad
An alternative to investing via an ISA in the UK would indeed be to use a Spanish broker or bank etc instead. But you would likely then have the hassle of declaring any gains and income to HMRC via (probably) a self-assessment's foreign pages, while those gains and income would be tax-free in an ISA.