NB: Travel is currently ill-advised unless you're fully vaccinated due to very high cases levels all around the world. Consider postponing your trip or instead traveling to a country where you can get vaccinated locally, such as the US, if you haven't been vaccinated just yet.
Flying directly to Spain? No, unless you've been vaccinated with an EU-approved vaccine (which aren't available in Cuba yet, as they're using local ones instead?) as described by @mlc. But there's always the Croatia loophole, which has been available for more than a year now to gain access to any EU country regardless of your residency. Croatia is visa-free for Ukrainian citizens so this option will work for you.
According to IATA, the following foreign citizens may enter Spain:
passengers arriving from Austria, Belgium, Bulgaria, Croatia, Cyprus, Czechia, Denmark, Estonia, Finland, France, Germany, Greece, Hungary, Iceland, Ireland (Rep.), Italy, Latvia, Liechtenstein, Lithuania, Luxembourg, Malta, Netherlands, Norway, Poland, Portugal, Romania, Slovakia, Slovenia, Sweden or Switzerland;
So passengers traveling from Ukraine are not included unless there's residents. However there's a "loophole" where you can first enter Croatia and then fly to any EU country of your choosing. The IATA page has the following requirements for Croatia:
- passengers traveling as tourists with proof of paid accommodation;
The Croatian National Tourist Board confirms this:
Third-country nationals not covered by the above mentioned points may
enter the Republic of Croatia from third countries if they are:
- persons who travel for tourist reasons and have confirmation of paid accommodation in a hotel, camp, private renter or rented vessel
and other form of tourist accommodation or are owners of houses or
vessels in the Republic of Croatia;
Persons referred to in items 7,
8, and 9 will be allowed to enter the Republic of Croatia with:
- Presentation of a certificate of negative PCR or rapid antigen test for SARS-CoV-2 listed on the Joint List of Rapid Antigen Tests
Mutually Recognized by the Member States of the European Union,
published by the European Commission, if the test result is not older
than 48 hours testing until arrival at the border crossing.
So what you could do is fly from Cuba to Croatia (I'm seeing an Air France flight that could work, as France still allows for transit), stay there for a day and then fly to Spain. Note that you'll need a COVID test in both Cuba and Croatia. On the way back you could just fly straight from Spain to Cuba.