It is known that any primitive pythagorean triple $a^2 + b^2 = c^2$ is on the form
$$
(a, b, c) = (2uv, u^2 - v^2, u^2 + v^2)
$$for some natural numbers $u>v$, so you basically have to check whether your hypotenuse can be written as the sum of two squares. To confirm your examples, $5 = 4 + 1$, and $13 = 9 + 4$, while $12$ is not the sum of two squares (you can't add your way to $12$ by using only two numbers from $\{1, 4, 9\}$).
If course, it's possible that your number could be the hypotenuse in some non-primitive triple. This happens if it has a divisor that can be written as the sum of two squares. For instance, if at least one of its prime factors are congruent to $1$ modulo $4$.