Answer
$I= \dfrac{M}{ 3 L} \left[ (L-d)^3+d^3 \right]$
Work Step by Step
We know that the moment of inertia is given by
$$I=\int x^2 dm\tag 1$$
Since the mass of uniformly distributed through the length of the rod, then its density is given by
$$\rho =\dfrac{M}{V}=\dfrac{dm}{dV}$$
Hence,
$$ \dfrac{M}{ \color{red}{\bf\not}AL}=\dfrac{dm}{ \color{red}{\bf\not}Adx}$$
where $A$ is the cross-sectional area of the rod.
$$ \dfrac{Mdx}{ L}= dm $$
Plugging into (1);
$$I=\int x^2 \dfrac{Mdx}{ L} $$
As seen in the figure below, we chose our origin to be the black dot.
Thus,
$$I=\dfrac{M}{ L} \int_{-d}^{L-d} x^2dx $$
$$I=\dfrac{M}{ L} \left[ \dfrac{x^3}{3}\right]\bigg|_{-d}^{L-d}=\dfrac{M}{ 3 L} \left[ (L-d)^3-(-d)^3 \right] $$
Thus,
$$I= \dfrac{M}{ 3 L} \left[ (L-d)^3-(-d)^3 \right] $$
$$\boxed{I= \dfrac{M}{ 3 L} \left[ (L-d)^3+d^3 \right] } $$
________________________________________________
When $d=0$,
$$I= \dfrac{M}{ 3 L} \left[ (L-0)^3+0^3 \right]= \dfrac{M}{ 3 L} L^3$$
$$\boxed{I= \dfrac{ML^2}{ 3 }} $$
which is the same result as Table 12.2.
________________________________________________
And when $d=\frac{L}{2}$,
$$I= \dfrac{M}{ 3 L} \left[ \left(L-\frac{L}{2}\right)^3+\left(\frac{L}{2}\right)^3 \right]= \dfrac{M}{ 3 L} \left[ \left( \frac{L}{2}\right)^3+\left(\frac{L}{2}\right)^3 \right]$$
$$I= \dfrac{2M}{ 3 L} \left[ \frac{L^3}{2^3} \right]$$
$$\boxed{I= \dfrac{ML^2}{ 12}} $$
which is the same result as Table 12.2.