More generally,
if $i < j < k$,
suppose the
$i$-th, $j$-th,
and $k$-th terms
in an arithmetic progression
are in a geometric progression
with ratio $r$.
I will show that
(1) if $ik \ne j^2$
then $r=\frac{k-j}{j-i}$;
(2) if $ik = j^2$
then $r=\frac{j}{i}$.
We have
$r
=\frac{a+jd}{a+id}
=\frac{a+kd}{a+jd}
$.
Cross-multiplying,
$(a+id)(a+kd)
=(a+jd)^2
$
so
$a^2+(i+k)ad+ikd^2
=a^2+2ajd+j^2d^2
$
or
$d(d(j^2-ik)+a(2j-(i+k)))
= 0
$.
Therefore either
$d = 0$
or
$d(j^2-ik)+a(2j-(i+k))=0$.
As a check,
with
$i=1, j=2, k=5$
in the OP,
this is
$-d-2a=0$,
which matches.
So we must have
$d(j^2-ik)+a(2j-(i+k))=0$.
There are two cases,
depending if
$ik \ne j^2$
or
$ik = j^2$.
If $ik \ne j^2$,
$d
=\frac{a(2j-(i+k))}{ik-j^2}
$.
Then,
$\begin{array}\\
r
&=\dfrac{a+jd}{a+id}\\
&=\dfrac{a+j\frac{a(2j-(i+k))}{ik-j^2}}{a+i\frac{a(2j-(i+k))}{ik-j^2}}\\
&=\dfrac{a(ik-j^2)+j(a(2j-(i+k)))}{a(ik-j^2)+i(a(2j-(i+k)))}\\
&=\dfrac{ik-j^2+2j^2-j(i+k)}{ik-j^2+2ij-i(i+k)}\\
&=\dfrac{j^2-ij-jk+ik}{-j^2+2ij-i^2}\\
&=\dfrac{j(j-i)-k(j-i)}{-(i-j)^2}\\
&=\dfrac{(k-j)(j-i)}{(j-i)^2}\\
&=\dfrac{k-j}{j-i}\\
\end{array}
$
In the OP's case,
we get
$\frac{5-2}{2-1}
=\frac{3}{1}
= 3
$,
which, again, matches.
If $ik = j^2$,
then
$a(2j-(i+k))=0
$.
If $a=0$,
then
$r
= \frac{j}{i}
= \frac{k}{j}
$
and any $d$ works.
If $a \ne 0$,
then
$2j = i+k$.
Then
$(i+k)^2
= 4j^2
=4ik
$
so
$i^2+2ik+k^2
=4ik$
or
$(i-k)^2 = 0$.
This contradicts
our original assumption
of $i < j < k$,
so this can not happen.
Therefore we can always
get the ratio,
without knowing
the initial or increment values.