Hello @Boxer
I found a website that has a FAQ section about the asylum procedure in Spain. According to it, it seems that you can apply for asylum at Madrid airport:
Q: "Where can I submit my application for asylum?"
A: "At any border checkpoint in Spanish territory, at ports and airports; at any asylum and refuge office (OAR); and any immigrant detention centre (CIE)."
Source: ****://ciutatrefugi.barcelona/en/international-protection-and-asylum-seeking-spain
As far as I can see you don't need to have a transit visa to get there. On this website (****://***.exteriores.gob.es/Portal/en/ServiciosAlCiudadano/InformacionParaExtranjeros/Paginas/Visadosdetránsitoaeroportuario.aspx) they didn't list Azerbaijan as one of the countries that need to have a transit visa.
But I'm not sure if you will be able to enter the plane to Spain without a visa for the UK though.
In the transit area you should get in contact with (border)-police or other officials and tell them that you seek protection and that you want to apply for asylum in Spain.
In case your application gets refused you will most likely either be send back to your home country or the country that you came from by plane.
Best regards,
Thorgen