Answer
$ T= \dfrac{M}{L}yg $
Work Step by Step
We need to divide the length of the rope into infinitesimal pieces of $dy$, as you see in the figure below.
The mass of this $dy$ is given by
$$\rho=\dfrac{dm}{dV}$$
Thus,
$$dm=\rho dV $$
Recall that the volume of the rope is similar to the volume of a cylinder, $V=AL$ whereas $A$ is its cross-sectional area and $L$ is its length.
$$dm=\rho Ady\tag 1$$
The net force exerted on $dm$ is zero since the whole system is at rest.
Thus,
$$\sum F_{y}=T- m_yg=0$$
Hence,
$$T= m_yg\tag 2$$
whereas $m_yg$ is the weight of the segment $y$.
Noting that
$$dm=\rho Ady=\dfrac{M}{AL}Ady=\dfrac{M}{L}dy$$
$$\int dm=\int \dfrac{M}{L}dy$$
$$m_y=\dfrac{M}{L}y$$
Plugging into (2);
$$\boxed{T= \dfrac{M}{L}yg}$$
where $M$ is the mass of the whole rope and $L$ is its whole length.