score:3
40 minutes to change trains should be more than enough since all you have to do is move from one platform to the other within the same station - Italo and Trenitalia trains both arrive in the same station i.e. Milano Centrale. However, any delay will obviously impact your ability to make it. Unfortunately, since you are using two different companies, I do not think that Trenitalia will guarantee you an onward journey of you miss your train due to a delay on an Italo journey. Indeed you have two separate transport contracts here and no obligation from either company to fulfill the other company's obligations.
Your best bet is to travel both legs with the same operator and get the most flexible ticket fare possible so that you can easily change the ticket even after departure.