I found this answer to be useful: Is there an equation to describe regular polygons?
You can use absolute values or modular arithmetic to take care of the discontinuities. Here's one possible formula, which will trace out an equilateral triangle centered on the origin:
Let $k \equiv \frac{2\pi}{3}$. (In general, we divide $2\pi$ by the number of sides of the polygon we want to draw).
$$\begin{align*}
r(\theta) = \frac{\cos{\left(\frac{k}{2}\right)}}{\cos{\left(-\frac{k}{2} + \;\theta \,\text{mod}\; k\right)}}
\end{align*}$$
And you can plot this for every value of $\theta$ between 0 and $2\pi$.
If you want a larger triangle, multiply $r(\theta)$ by a suitable number. And if you want to rotate the triangle, replace $\theta$ with $\theta+d$
for some rotation amount $d$.
Finally, if you want to have a formula in rectangular coordinates, you can use the polar-to-rectangular transformation:
$$\begin{align*}x(\theta) &= r(\theta)\times \cos{\theta}\\y(\theta)&=r(\theta)\times \sin{\theta} .\end{align*}$$
I hope that helps!