Here $p$ must be an odd prime.
There are two cases to consider, $p\equiv 1 \pmod 4$ and $p\equiv 3 \pmod{4}$. We deal with the first case.
We know that $(p-1)!\equiv -1\pmod{p}$. Rearrange the numbers from $1$ to $p-1$, so that we get the odd numbers from $1$ on going up, interleaved with the even numbers from $p-1$ going down. For example, if $p=13$, we arrange the numbers from $1$ to $12$ in the order $1$, $12$, $3$, $10$, $5$, $8$, $7$, $6$, $9$, $4$, $11$, $2$.
In general the listing is $1$, $p-2$, $3$, $p-3$, $5$, $p-5$, and so on until at the end we get to $p-2$, followed by $p-(p-2)$. Now take the product, in that order, noting that $p-k\equiv -k \pmod{p}$.
We get that $(p-1)!\equiv (1)(-1)(3)(-3)(5)(-5)\cdots (p-2)(-(p-2))\equiv -1\pmod{p}.\tag{$1$}$ The number of even numbered entries in the product is $(p-1)/2$. These have minus signs in front of them. Gather the minus signs together. We get $(-1)^{(p-1)/2} 1^23^25^2\cdots (p-2)^2 \equiv -1\pmod{p}.$ Note that $(p-1)/2$ is even. So we get that
$1^23^25^2\cdots (p-2)^2 \equiv -1\pmod{p}.$ Now we are finished, since $-1=(-)^{(p+1)/2}$.
The argument for $p\equiv 3\pmod{4}$ is essentially the same. In fact the two arguments could be gathered into one. The main difference is that in $(1)$, the number of minus signs, which is $(p-1)/2$, now turns out to be odd. So we get $-1^23^25^2\cdots (p-2)^2 \equiv -1\pmod{p}.$ or equivalently $1^23^25^2\cdots (p-2)^2 \equiv 1\pmod{p}.$ Since in this case we have $(-1){(p+1)/2}=1$, again the result follows.
Remark: The above shows the useful result that if $p\equiv 1\pmod{4}$, then there is an $x$ such that $x^2\equiv -1\pmod{p}$. Indeed it gives an explicit expression for such an $x$. Regrettably, the expression is not computationally useful if $p$ is large.