score:2
Yes, you are supposed to submit a comprehensive and, obviously, truthful itinerary. So if you intend to go to Spain you need to indicate that in your application. And if you mention the Spanish part of the trip, submitting relevant evidence is indeed necessary. Having an officially sanctioned invitation from your friend accounts for the accommodation, strengthen your premise and helps show you can afford the trip.
Under the Schengen system, countries effectively delegate (a part of) their authority to issue short-term visas to other Schengen countries (under certain conditions) but the Italian consulate certainly can and should evaluate the whole trip.
In practice, if you have a decent application and you dot the i's and cross the t's for your Italian trip, you could probably get away with omitting your trip to Spain. Once you have the visa, changing your mind and adding an incidental stay in another Schengen country isn't forbidden. But it could theoretically backfire if someone somehow notices you initially misrepresented your intentions.