Let's first consider the problem the way you phrase it. Then, from first principles, the answer to "When we are talking about the acceleration of the whole system, do I need to consider all three masses" is an unequivocal "yes": The machine is a system with only one external horizontal force F acting on it. We don't need to know anything about its inner workings but can say with confidence that the external force accelerates the entire system (i.e., the center of mass of $M_a = M_1 + M_2 + M_3$) corresponding to Newton's laws:
$F = m_a*a$.
We can see that M2 may move horizontally relative to M1; therefore, the speed of the entire system (i.e., its center of mass) may be different from that of its base M1, because of the contribution of M2 moving at a different speed.
Let's investigate a few interesting cases (I'll use "Mx = 0" as a short form for "negligibly small").
M3 = 0
In this case, any force applied to M1 accelerates only M1 which slides off from under M2. M1 accelerates faster than $a_a = F/(M_1+M_2+0)$ would suggest, but only until M3 hits the pulley.
F = 0
Because there is no external force, the center of mass is not accelerated; M3 will fall and M2 will accelerate right, while M1 and M3 will accelerate left. The horizontal speeds will be inversely proportional to the masses of $(M_1+M_3)$ and $M_2$.
F is the force needed to keep M1 stationary
This is an interesting case because energy and momentum are decoupled. The force accelerating M2 acts also, via the pulley, equally but opposite on M1; because our precondition is that we exactly counteract it, M1 does not move. Instead, only M2 is accelerated horizontally (and M3 vertically). This implies that the entire system $(M_1+M_2+M_3)$ gains horizontal momentum here, exactly according to the force we apply multiplied by the time: $p = F*t$. That the point the force is applied to does not move M1 is irrelevant for the momentum gain1. It is not, however, irrelevant for the energy gain: Pulling against a stationary object does not do any work, i.e., does not transfer energy. The kinetic energy of M2 is part of the potential energy M3 lost on its way down. But, inversely, the vertical acceleration of M3 cannot change the horizontal momentum of M2 — as we said, the change in momentum comes from the external force we exerted. Energy and momentum changes are entirely decoupled.
By the way, the force acting on M2 and oppositely on M1, i.e. the tension in the rope, is not, as I previously thought, M3's weight $M_3*g$. The reason is that M3's weight is accelerating both masses. For a very heavy M3 and a light M2, it is obvious that the rope will not carry all of M3's weight. We have
$$F=m*a$$
with $F=M_3*g$ and $m=M_2+M_3$:
$$M_3*g = (M_2+M_3)*a$$
Solving for a:
$$\frac{M_3*g}{M_2+M_3} = a$$
Which makes sense: For negligible M2 or huge M3, the acceleration approaches g, for huge M2 0 or negligible M3, it approaches 0.
Now we can compute the force $F2_{accel}$ needed to accelerate M2 with this acceleration, which is the tension in the rope and the opposite force on M1 (via the pulley). Again we simply use $F=m*a$, with the acceleration we just computed but with m this time only M2:
$$F2_{accel} = M_2*\frac{M_3*g}{M_2+M_3}$$
Interestingly, if we slightly rewrite this it becomes clear that even though the problem appears highly asymmetric, this is an entirely symmetrical formula:
$$F2_{accel} = \frac{M_2*g*M_3}{M_2+M_3}$$
Exchanging masses M2 and M3 does not change the tension in the rope! For equal masses, this is clear; for highly different masses $M_{tiny}$ and $M_{huge}$, the force cannot exceed $M_{tiny}*g$, either because that is the weight (as $M_3$) or because $M_{tiny}$ as $M_2$ will be accelerated with almost g by the falling $M_{huge}$ as $M_3$.
F2accel = M3*g
This is a bit tricky and needs exposition.
Let's start with a resting M1. In this case, the weight of M3 accelerates both M2 and M3. The force needed to accelerate M2 — the tension in the rope — is dependent on the acceleration and on M2. For a very light M2, the combined mass approaches M3 and the overall acceleration consequently g; very little force is needed to accelerate M2 with almost g. Correspondingly, there is very little tension on the rope. By contrast, for a very heavy M2, the overall mass that needs to be accelerated by the constant weight of M3 is large, and the resulting acceleration will be small. The tension in the rope will approach the weight of M3, $M_3*g$. If the tension in the rope is exactly $M_3*g$, M3's weight will be entirely held by the rope, and consequently M3 will not accelerate vertically, and M2 will not accelerate horizontally relative to M1. (It will, of course, accelerate in absolute terms according to the force acting on it, as will the other parts of the machine.)
This is the state we want to achieve. For that, we can accelerate M1 which will exert a horizontal accelerating force on M2 and a corresponding, opposing vertical force on M3 via the pulley; this will increase the tension in the rope. The tension — the accelerating force — must equal the weight of M3 if M3 is supposed to be vertically stationary; all its weight will be on the rope:
$$F2_{accel} = M_3*g$$
With $F2_{accel}=M_2*a$:
$$M_2*a = M_3*g$$
Solving for a:
$$a = g*M_3/M_2$$
The acceleration a extends to the entire system M1 + M2 + M3, since no part is horizontally moving relative to each other, therefore, with $F = m*a$ and $a = g*M_3/M_2$:
$$F = (M_1+M_2+M_3)*g*M_3/M_2$$
We see that M3 has a quadratic influence on the needed force: It accelerates M2 more, and its inertia must be overcome when accelerating the overall system.
We also see that when M2 shrinks, the acceleration needed for an inertial force that matches $M_3*g$ grows; to achieve higher accelerations, in turn, we need a larger F to accelerate the overall mass. This is true even though $(M_1+M_2+M_3)$ shrinks somewhat with a shrinking M2: With a shrinking M2, the fraction $M_3/M_2$ approaches infinity while the overall mass needing acceleration settles at the very finite $M_1+M_3$.
1 It should be noted that in all these experiments, the momentum changes of the overall system, horizontally through the external force F and vertically by the accelerating M3, are exactly compensated by corresponding opposite changes in Earth's momentum. (Yes, a hammer falling on its own hits the ground earlier than a feather falling on its own because it accelerates the Earth more towards itself while it's falling.)