One simple way is to use approximation techniques which work for
real numbers. In this case, the Wikipedia article Methods of computing square roots refers to the Babylonian method:
Perhaps the first algorithm used for approximating $\sqrt{S}$ is known as the Babylonian method, despite there being no direct evidence beyond informed conjecture that the eponymous Babylonian mathematicians employed this method.$^{[1]}$ The method is also known as Heron's method,
This is a special case of finding square roots
(which can also be used for
polynomial roots) of Newton's method for $p$-adic numbers.
In p-adic analysis, the standard method to show a polynomial equation in one variable has a $p$-adic root is Hensel's lemma, which uses the recursion from Newton's method on the $p$-adic numbers.
In the specific case of $\sqrt{-1}\,$ in $\mathbb{Z}_5$ the calculations
go as follows. Start with an approximation such as $\,x_0 = 2+O(5^5).\,$
Next, $\,x_1 = (x_0 +\frac{-1}{x_0})/2 = (2 + \frac{3124}{2})/2 = 782+O(5^5).\,$ Next, $\,x_2 = (x_1 + \frac{-1}{x_1})/2 = 1432+O(5^5).\,$ Finally, $\,x_3 = (x_2 + \frac{-1}{x_2})/2 = 2057
+O(5^5).\,$ The calculations are all done modulo $5^5$.
Another method is to iterate the Frobenius endomorphism. Again, start
with $\,y_0 = 2+O(5^1).\,$ Next, $\,y_1 = y_0^5 = 32+O(5^2) = 7+O(5^2).$
Next, $\,y_2 = y_1^5 = 7^5 + O(5^3) = 57 + O(5^3).$ Next,
$\,y_3 = y_2^5 = 182 + O(5^4).\,$ Finally, $\,y_4 = y_3^5 =
2057 + O(5^5).\,$ One advantage of
this method is that each iteration yields one more digit and the
final precision is not fixed in advance. Also, only multiplications are used. The computations can be easily done with
PARI/GP as follows
gp> x = 2+O(5^5); y = 2 + O(5^1);
gp> for(n=1,5, print([x,lift(x)],"\t",[y,lift(y)]); x=(x+(-1)/x)/2; y=y^5)
[2+O(5^5),2] [2+O(5),2]
[2+5+5^2+5^3+5^4+O(5^5),782] [2+5+O(5^2),7]
[2+5+2*5^2+5^3+2*5^4+O(5^5),1432] [2+5+2*5^2+O(5^3),57]
[2+5+2*5^2+5^3+3*5^4+O(5^5),2057] [2+5+2*5^2+5^3+O(5^4),182]
[2+5+2*5^2+5^3+3*5^4+O(5^5),2057] [2+5+2*5^2+5^3+3*5^4+O(5^5),2057]
gp>
Of course, PARI/GP can compute the square root directly using
sqrt(-1+O(5^5)).
The specific case of $\sqrt{-1}\,$ in $\mathbb{Z}_3$ is easier
because there is no quadratic residue congruent to $-1$ modulo $3$
and this implies that there is no solution to $\,x^2+1\equiv 0
\pmod 3$ and hence no solution to $\,x^2+1=0\,$ in $\mathbb{Z}_3$.
It is instructive to find out why the two methods used to find
solutions $\mathbb{Z}_5$ fail in $\mathbb{Z}_3$.