The biggest part of your problem is finding out the right formulation. I formulate it like this: let there be a body of mass $M$, volume $V$, and a constant density $\rho = M/V$ that is within a ball $B_R$ of radius $R$ around its center of mass. What shape, holding the parameters above fixed, maximizes the mass quadrupole $Q$ of the body?

Let us pick spherical coordinates $r,\vartheta,\varphi$. Let me assume axisymmetry for now, and you can verify later that it cannot extremize the problem further. We then use the formula for the mass quadrupole in terms of spherical harmonics, divide it by the total mass, and find out that we are then maximizing the following expression with respect to $V$

$$\frac{Q}{M} = \frac{\int_V r^2\frac{1}{2}(3 \cos^2 \vartheta-1) 2 \pi r \sin \vartheta dr d\vartheta}{\int_V 2 \pi r \sin \vartheta dr d\vartheta}$$

where I have cancelled the factor $\rho$ in both the expressions but let the geometric factors uncancelled for better transparency.

Technically, I do not immediately see how to make a tidy expression $\delta Q/ \delta V$ while keeping the body within $B_R$, but I know the solution to the problem because it is obvious from the structure of the extrema of the harmonic $r^2(3 \cos^2 \vartheta-1)/2$. The extrema do not exist within the domain of finite volumes $V$. However, there are two asymptotic extrema corresponding to an extremely prolate ($Q>0$) and extremely oblate ($Q<0$) body. They are respectively the infinitesimal volumes around two points at the poles $\vartheta = 0,\pi$ at a distance $R$ from the center, and an infinitely thin ring at $\vartheta=\pi/2$ of radius $R$.