This answer has been revised from its original version in order to take into account the following comment on the question:
The problem is to maximize all cones and spheres forming an ice cream like this.
Let's suppose we are permitted to vary the size of the sphere and the size and shape of the cone as much as we want, with the goal of achieving the maximum ratio of the volume
$\newcommand{Vcap}{V_\text{cap}}\Vcap$
of the portion of the sphere inside the cone (which is a spherical cap)
to the volume $\newcommand{Vcone}{V_\text{cone}}\Vcone$ of the entire cone.
Note that this a very different thing from saying "the cone is fixed."
A fixed cone means we can only vary the size of the sphere, not any property of the cone.
The size and shape of the cone can be completely described by two variables. There are several plausible options for which two variables to use, but they all describe the same range of sizes and shapes. I'll use the angle
$\theta = \angle BAG$ and the height of the cone, $y = AG.$
The sphere can only vary in size, which is completely determined by its radius, $r.$ So we now have three variables to play with, and the volumes of the cone and the spherical cap can be expressed as functions of these variables:
$\Vcone(\theta, y)$ and $\Vcap(\theta, y, r).$
The problem comes with some restrictions on the three variables.
The cone and the spherical cap must both have positive volume,
for otherwise $\Vcap/\Vcone$ is zero or undefined.
Positive volume of the cone implies that
$0 < \theta < \frac\pi2$ and $y > 0.$
Positive volume of the spherical cap implies that
$r > 0$ and $y > x - r,$
where $x = r\csc\theta$ is the distance from the vertex of the cone to the center of the sphere.
But notice that if we multiply $y$ and $r$ by some factor (the same factor for both)
and don't change $\theta,$
the volumes of the cone, the sphere, and the spherical cap all increase or decrease by a common factor.
For example, if we double the lengths $r$ and $y,$ all the volumes increase by a factor of $8.$
The ratios of the volumes do not change.
This implies that the maximum of
$\Vcap(\theta, y, r)/\Vcone(\theta, y),$
if there is a maximum,
can be achieved at any value of either $y$ or $r$ that we want.
To do this, take any combination of $\theta,$ $y,$ and $r$ that maximizes
$\Vcap(\theta, y, r)/\Vcone(\theta, y),$
and scale it up or down so that the value of $y$ (or $r$)
is the value we want.
So we could assume, for example, that $y = 1$ and then maximize
$\Vcap(\theta, 1, r)/\Vcone(\theta, 1)$
over all $\theta$ and $r.$
Alternatively, we could suppose that $r = 1$ and then maximize
$\Vcap(\theta, 1, r)/\Vcone(\theta, 1)$
over all $\theta$ and $y.$
Having tried both, I'll assume $r = 1,$
since the formulas seem not to get messy quite as quickly that way.
We now have a function of two variables that we wish to maximize,
$$ f(\theta, y) = \frac{\Vcap(\theta, y, 1)}{\Vcone(\theta, y)}, $$
where $0 < \theta < \frac\pi2$ and $y > \csc\theta - 1.$
There is a widely-used method to maximize a function of two variables,
setting both partial derivatives of the function simultaneously to zero in order to find the critical points of the function.
This method assumes that the domain of the function is a closed set, however,
and our domain is not closed.
Moreover, it turns out not to be possible to to reduce the problem to a maximization over a closed domain.
An alternative method is illustrated in an answer to another question.
We can follow a similar line of reasoning as follows:
First we define a function $g(\theta)$ for $0 < \theta < \frac\pi2$:
$$
g(\theta) = \max_{y > \csc\theta - 1} f(\theta, y).
$$
We must show that this function actually is defined
(that is, a maximum is achieved) for every $\theta$ such that
$0 < \theta < \frac\pi2.$
We then maximize $g(\theta)$ over $0 < \theta < \frac\pi2$:
$$
M = \max_{0 < \theta < \frac\pi2} g(\theta).
$$
If this maximum value exists, then
$M = g(\theta_1) = f(\theta_1,y_1)$
for some $\theta_1$ and $y_1$ such that
$0 < \theta_1 < \frac\pi2$ and $y_1 > \csc\theta_1 - 1.$
Then for any $(\theta_2, y_2)$ for which $f(\theta_2, y_2)$ is defined,
we have $0 < \theta_2 < \frac\pi2,$ $y_2 > \csc\theta_2 - 1,$ and
$$
M = g(\theta_1) \geq g(\theta_2) \geq f(\theta_2, y_2).
$$
Therefore $M = f(\theta_1,y_1)$ is the maximum of $f$ over its entire domain.
In order to find the function $g(\theta),$ we (temporarily) assume an arbitrary fixed value of $\theta$ such that
$0 < \theta_2 < \frac\pi2,$ and then maximize
$\Vcap(\theta, y, 1)/\Vcone(\theta, y)$
over all $y > \csc\theta - 1.$
We can reduce the domain of the maximization by observing that if $y > \csc\theta + 1,$
then $\Vcap(\theta, y, 1) = \Vcap(\theta, \csc\theta + 1, 1)$
but $\Vcone(\theta, y) > \Vcone(\theta, \csc\theta + 1).$
Hence $f(\theta, y) < f(\theta, \csc\theta + 1).$
The maximum of $f,$ if there is one, must occur when $y \leq \csc\theta + 1.$
Assuming $x - 1 < y \leq x + 1,$
where $x = \csc\theta,$
the height of the spherical cap is
$h = r + y - x = y + (1 - x).$
We can use the formula
$
\Vcap(\theta,y,r) = \frac13\pi h^2(3r - h),
$
adapted from Wolfram Mathworld.
This gives us
\begin{align}
\Vcap(\theta, y) &= \frac13\pi (y + (1 - x))^2(3-(y + (1 - x))) \\
& = \frac13\pi (x^3 - 3x + 2 + (3-3x^2)y + 3xy^2 - y^3) \\
\end{align}
Observing that this function is zero when $y = x - 1,$
we can take the maximum over $x - 1 \leq y \leq x + 1,$
knowing that the maximum will always be achieved somewhere in that interval
other than at $y = x - 1.$
The volume of the cone is
$$
\Vcone = \frac13 \pi R^2 y = \frac13\pi y^3 \tan^2\theta
$$
where $R = y\tan\theta$ is the radius of the base of the cone.
So
\begin{align}
f(\theta, y)
& = \frac{\frac13\pi (x^3 - 3x + 2 + (3-3x^2)y + 3xy^2 - y^3)}
{\frac13\pi y^3 \tan^2\theta} \\
& = \left(\frac{x^3 - 3x + 2}{y^3} + \frac{3(1-x^2)}{y^2}
+ \frac{3x}{y} - 1\right)\cot^2\theta
\end{align}
for $x-1 \leq y \leq x+1.$
This is maximized either when $y = x-1,$ when $y=x+1,$ or when
\begin{align}
0 &= \frac{\partial}{\partial y} f(\theta, y) \\
& = \left(-3\frac{x^3 - 3x + 2}{y^4}
+ -2\frac{3(1-x^2)}{y^3} - \frac{3x}{y^2}\right)\cot^2\theta \\
&= -\frac{3\cot^2\theta}{y^4} (xy^2 + 2(1-x^2)y + x^3 - 3x + 2)
\end{align}
(keeping in mind that $x$ is a function of $\theta$ but not a function of $y.$)
We can rule out a maximum at $y = x-1$ (because $f = 0$)
or $y=x+1$ (because $\partial f/\partial y < 0$),
so the maximum occurs when $xy^2 + 2(1-x^2)y + x^3 - 3x + 2 = 0.$
This is a quadratic equation in $y$ with roots
$y = x - 1$ and $y = x - \frac2x + 1.$
We have already ruled out $y = x - 1,$ so the maximum must occur at
$$
y = x - \frac2x + 1 = \csc\theta - 2\sin\theta + 1.
$$
This implies that $h = 2 - 2\sin\theta$ and
$$
g(\theta) = \frac{h^2(3r - h)}{y^3 \tan^2\theta}
= \frac{(2 - 2\sin\theta)^2(2\sin\theta + 1)}{(\csc\theta - 2\sin\theta + 1)^3} \cot^2\theta.
$$
After this point the calculations get increasingly ugly.
Appealing to Wolfram Alpha to
plot this function
and to
find the zeros of its derivative,
it looks as if the global maximum in the region
$0 < \theta < \frac\pi2$
would occur near $\theta = \frac\pi2,$
except that the function (at least in the form written above)
is not actually defined at $\theta = \frac\pi2.$
Instead, $g(\theta)$ is increasing over the entire interval
$0 < \theta < \frac\pi2,$
with
$$
\lim_{\theta\to\pi/2} g(\theta) = \frac{8}{9}.
$$
This is therefore the upper bound of $\Vcap/\Vcone,$
approached by a very wide, short cone containing a wide, thin spherical cap.
This result agrees with the calculations in another answer to this question.
For reference (because of numerous comments below which would not make sense without this context), here is my previous answer, which assumed the size and shape of the cone were fixed:
Let $x$ be the distance $AM,$ initially unknown to you.
By examining the dimensions of the cone (as suggested in comments)
you can determine the constant ratio $k = EM/AM = r/x,$ where $r$ is the radius of the sphere. Then $r = kx.$
The portion of the sphere inside the cone is a spherical cap
(defined as the part of the sphere on one side of a plane,
in this case the part below the plane of the cone's base).
This spherical cap has a height $h$ (the distance from the bottom of the
sphere to the base of the cone);
in fact, $h$ is the sum of the sphere's radius $r$ plus the distance from $M$ upward to the base of the cone.
(If $M$ is above the base of the cone then the distance "upward" from $M$
to the base is negative.)
If you put all this together, replacing $r$ with the appropriate multiple of $x,$ you should be able to write an equation
of the form $h = px + q.$
You can now use one of the formulas for
the volume of a spherical cap; in particular this formula should be a nice one:
$$
V = \frac13\pi h^2(3r - h).
$$
Since $r=kx$ and $h = px+ q,$ plugging in these values we can
rewrite $\frac13\pi h^2(3r - h)$ as an expression in which the
only unknown value is $x.$
That expression will be a cubic polynomial.
You can then apply the usual single-variable calculus approach
to maximizing the value of a function.
That is, to find the maximum volume $V,$ take the derivative of the polynomial (which is a quadratic in $x$) and set it to zero.
The maximum volume occurs either at a value of $x$ for which the
derivative of the volume is zero or at the minimum or maximum possible
value of $x$ (in this case, $x=0$ or $x$ so large that the
sphere is just tangent to the cone at the circle around the base of the cone).