In number theory we learn when $2$ is a quadratic residue: $ \left( \frac{2}{p}\right) = (-1)^{\frac{p^2 - 1}{8}}$
It takes a moment to verify that $\displaystyle \frac{p^2 - 1}{8} \in \mathbb{Z}$ always. To me the $2$ is a bit arbitrary. Why is $2$ special?
Is there an analogous formula for $(\frac{3}{p})$ of the type $(-1)^?$
Using quadratic reciprocity one shows $3 \equiv \square \mod p$ if and only if $ p = \pm 1 \mod 12 $ (and never when $p = \pm 5 \mod 12$) It takes quite a bit of math to show both of these classes of primes are infinite!!!
The case of $(\frac{2}{p})$ can be proven without Quadratic reciprocity from Fermat's theorem. I am wondering if $(\frac{3}{p})$ can as well.
I can try:
$$ \left(\frac{3}{p}\right) = (-1)^{\frac{p-1}{2}\cdot \frac{3-1}{2}} \left(\frac{p}{3}\right) $$
I will assume $p>3$. You can do the second part without using quadratic reciprocity. First, we will prove that $$-3 \text{ is a quadratic residue}\iff p\equiv 1\pmod 3$$ $$\left(\frac{-3}p\right)=1\iff \exists x: p|x^2+3\iff\exists y:p|(2y+1)^2+3$$ $$\iff p|4y^2+4y+4\iff p|y^2+y+1\iff p\not\lvert y-1,p|y^3-1$$ Let $g$ be a primitive root in $\bmod p$. If $3|p-1$, $y=g^{p-1\over 3}\ne1$, but $y^3=1$. On the other hand, if $3\not\lvert p-1$, then there exists $a,b$ such that $3a=(p-1)b+1$. So, if $y^3\equiv 1\pmod 3$ ; $$y\equiv y^{1+(p-1)b}\equiv(y^3)^a\equiv 1^a\equiv 1\pmod p$$ Thus, $$-3 \text{ is a quadratic residue}\iff p\equiv 1\pmod3$$
You can do the rest using the fact that $-1$ is a quadratic residue $\iff$ $4|p-1$ .
However, you can't have a formula like $(-1)^{qP(p)}$ for some polynomial $P\in\Bbb{Z}[X],q\in \Bbb Q$, as its value only depends on the power of $2$ in $P(p)$ and $q$.