$$p / ( p-1 ) ! + \left(\frac{a}{p}\right) a^{(p-1)/2}$$

Proof.

Consider the equation $Ax \equiv a \bmod p$ with $A, x \in \{ 1,2, \cdots p-1\}$,

Case $\left(\frac{a}{p}\right)=-1$

In this case $x$ and $A$ are different members of the set $\{ 1,2, \cdots p-1\}$, there are $(p-1)/2$ distinct pairs $(A, x) $ and pairwise multiplication gives the following identity: $( p-1 ) ! = a^{(p-1)/2}$.

Case $\left(\frac{a}{p}\right)=1$

In this case $a$ is a quadratic residue of $p$ so there are two pairs where $x$ and $A$ are equal members of the set $\{ 1,2, \cdots p-1\}$, there are $(p-3)/2$ distinct pairs $(A, x) $ and pairwise multiplication gives the following identity: $\frac {( p-1 ) ! }{k (p-k)}= a^{(p-3)/2}$.

Now $k( p-k) = kp - k^2 \equiv -a \bmod p $. Another pairwise multiplication gives the following identity: $( p-1 ) ! = - a^{(p-1)/2}$.

Combining both cases and replacing the sign with the Legendre symbol gives $$p / ( p-1 ) ! + \left(\frac{a}{p}\right) a^{(p-1)/2}.$$