AC Milan beat Bayern Munich on penalties after an entertaining 3-3 draw in the International Champions Cup.