Answer
$T = Mg + (1-\frac{y}{L})mg$
Work Step by Step
No matter where you are on the rope, there will be a gravitational force due to the mass, which is: $Mg$. However, how much rope tension there needs to be depends on how far from the top of the rope you are. Thus, it follows:
$T = Mg + (1-\frac{y}{L})mg$
Note, using this equation, when at the top of the rope (y=0), tension equals $Mg+mg$, which makes sense because it has to support both masses. However, at the bottom of the rope (y=L), tension equals Mg. This makes sense, for at the bottom of the rope, the force of tension no longer has to support the rope.