You can't. ISAs can only be provided by authorized ISA providersmanagers, 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. (Also note that attempting to become an authorized manager yourself is not feasible - see exclusions in https://www.gov.uk/guidance/apply-to-be-an-isa-manager !)
I wouldn't be too worried about problems if you open a UK ISA and then 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.