NO, it is not legal per EU Law:-
Every EU national is entitled to take up and pursue employment in the territory of another member state under the same conditions as the nationals of the host state (EU Treaty Art 1 and Regulation 1612/68).
If you have been rejected for the position and told specifically it was becasue you are not an Italian citizen, you have a claim (good luck). However, it is more likey that some other reason would have been given.
I note that some pilot jobs have recently been advertised that require fluency in the local language. This may also be illegal as the mandated language of aviation is English.
Some EU member states follow EU Labour Law, some don't, thereby protecting jobs for their own nationals.