For which sets of primes $P$ is there a finite type $\mathbb{Z}$-algebra $A$ such that$$p\in P\iff\mathrm{Hom}(A, \mathbb{F}_p)=\emptyset?$$Do all the finite $P$ arise this way?
$A=\mathbb{Z}/n$ works for the cofinite $P$.
For which sets of primes $P$ is there a finite type $\mathbb{Z}$-algebra $A$ such that$$p\in P\iff\mathrm{Hom}(A, \mathbb{F}_p)=\emptyset?$$Do all the finite $P$ arise this way?
$A=\mathbb{Z}/n$ works for the cofinite $P$.
The answer of RP_ is correct, so my main contribution is cleaning it up, providing more detail, and uniformising the different cases.
Definition. Let $\Omega$ be the set of prime numbers. For subsets $S, T \subseteq \Omega$, write $S \sim T$ if the symmetric difference $S \mathbin\triangle T = (S \setminus T) \cup (T \setminus S)$ is finite; note that this is an equivalence relation.
For a finite type $\mathbf Z$-scheme $X$, write $S_X$ for the set of primes such that $X(\mathbf F_p) \neq \varnothing$. If $X = \operatorname{Spec} A$ is affine, write $S_A$ for $S_X$. Finally, if $f \in \mathbf Z[x]$ is a polynomial, set $S_f = S_{\mathbf Z[x]/(f)}$, as in RP_'s answer. Define subsets of the power set $\mathcal P(\Omega)$ by \begin{align*} \mathcal P_{\text{sch}}(\Omega) &:= \{S_X \mathrel| X \in \mathbf{Sch}_{\mathbf Z}^{\text{f.t.}}\},\\ \mathcal P_{\text{aff}}(\Omega) &:= \{S_A \mathrel| A \in \mathbf{Alg}_{\mathbf Z}^{\text{f.t.}}\},\\ \mathcal P_{\text{poly}}(\Omega) &:= \{S_f \mathrel| f \in \mathbf Z[x]\},\\ \mathcal P_{\text{monic}}(\Omega) &:= \{S_f \mathrel| f \in \mathbf Z[x] \text{ monic}\}. \end{align*} In the main proposition below, we will show that the first three agree, and the fourth one as well if we only consider subsets of $\Omega$ up to $\sim$.
Example. The set of primes congruent to $1$ modulo $4$ is $S_{4x^2+1}$, since $-1$ is a square modulo a prime $p$ if and only if $p = 2$ or $p \equiv 1 \pmod 4$. In general, the Chebotarev density theorem says that elements of $\mathcal P_{\text{poly}}(\Omega)$ have rational density. For example, if $\mathbf Z[x]/(f) \cong \mathcal O_K$ is the ring of integers in a finite Galois extension $\mathbf Q \subseteq K$ of degree $n$, then $S_f$ has density $\tfrac{1}{n}$.
Remark. Note that $S_{X \times Y} = S_X \cap S_Y$ and $S_{X \amalg Y} = S_X \cup S_Y$, and more generally $S_{X \cup Y} = S_X \cup S_Y$ if $X,Y \subseteq Z$ are subschemes (not necessarily disjoint). This shows that $\mathcal P_{\text{sch}}(\Omega)$ and $\mathcal P_{\text{aff}}(\Omega)$ are closed under finite unions and intersections.
This also gives $S_{fg} = S_f \cup S_g$, since $\operatorname{Spec} \mathbf Z[x]/(fg)$ is the union $\operatorname{Spec} \mathbf Z[x]/(f) \cup \operatorname{Spec} \mathbf Z[x]/(g)$ (the intersection between the two components need not be empty, but it doesn't matter), so $\mathcal P_{\text{poly}}(\Omega)$ is closed under unions. In addition, the Corollary to Lemma 2 below shows that it is also closed under intersection.
Lemma 1. If $S \in \mathcal P_{\text{poly}}(\Omega)$ and $T \sim S$, then $T \in \mathcal P_{\text{poly}}(\Omega)$.
Proof. By assumption, there exists $f \in \mathbf Z[x]$ such that $S = S_f$. It suffices to show that if $p \in \Omega$, then $S \cup \{p\}$ and $S \setminus \{p\}$ are in $\mathcal P_{\text{poly}}(\Omega)$. For $S_f \cup \{p\}$, we may use $S_{pf}$. If $f = 0$, then $S_{px-1} = \Omega\setminus \{p\} = S \setminus \{p\}$, showing that $S \setminus \{p\} \in \mathcal P_{\text{poly}}(\Omega)$. If $f \neq 0$, choose $a \in \mathbf Z$ with $f(a) \neq 0$, and let $r = v_p(f(a)) \in \mathbf Z_{\geq 0}$. After replacing $f(x)$ by $f(x-a)$, we may assume $a = 0$. Then $g(x) = \tfrac{f(p^{r+1}x)}{p^r}$ has a solution modulo a prime $q \neq p$ if and only if $f$ does, since $p^{r+1}$ is invertible modulo $q$. This gives an integer polynomial whose terms are all divisible by $p$ except the constant term, so $g$ has no zeroes modulo $p$. Therefore, $S_g = S \setminus \{p\}$, showing that $S \setminus \{p\} \in \mathcal P_{\text{poly}}(\Omega)$. $\square$
Lemma 2. Let $f, g \in \mathbf Z[x]$. Then there exists a monic polynomial $h \in \mathbf Z[x]$ such that $S_f \cap S_g \sim S_h$.
Proof. Write $A = \mathbf Z[x]/(f)$ and $B = \mathbf Z[x]/(g)$, and set $C = A \otimes B$, so $S_f \cap S_g = S_C$. Then $(C \otimes \mathbf Q)^{\text{red}}$ is a finite product of fields, so can be written as $\prod_{i=1}^r \mathbf Q[x]/(h_i)$ for monic polynomials $h_i \in \mathbf Z[x]$. Then $C' = \prod_{i=1}^r\operatorname{Spec} \mathbf Z[x]/(h_i)$ differs from $(\operatorname{Spec} C)^{\text{red}}$ in finitely many closed fibres above $\operatorname{Spec} \mathbf Z$, so away from the corresponding primes we have $S_{C'} = S_C$. Setting $h = h_1 \dotsm h_r$ gives the result, since $S_{C'} = \bigcup_i S_{h_i} = S_h$. $\square$
Corollary. The set $\mathcal P_{\text{poly}}(\Omega)$ is closed under (finite) intersections.
Proof. If $S, T \in \mathcal P_{\text{poly}}(\Omega)$, then there exists $U \in \mathcal P_{\text{monic}}(\Omega)$ with $U \sim S \cap T$ by Lemma 2. Then Lemma 1 gives $S \cap T \in \mathcal P_{\text{poly}}(\Omega)$. $\square$
The main claim is the following:
Proposition. Let $S \subseteq \Omega$ be a set of primes. Then the following are equivalent:
That is, there exists a monic polynomial $f \in \mathbf Z[x]$ such that $S \mathbin\triangle S_f$ is finite. Note that this is not quite the Boolean lattice generated by the sets $S_f$, as $\mathcal P_{\text{aff}}(\Omega)$ is not closed under complements (e.g. it doesn't contain the set of primes congruent to $3$ modulo $4$, right?).
Proof of Proposition. Note that all sets contain singletons and complements of singletons, and are closed under finite unions and intersections (for intersections in $(4)$ and $(3)$, use Lemma 2 and its Corollary above). Implications $(3) \Rightarrow (2) \Rightarrow (1)$ are clear, and breaking up an arbitrary finite type $\mathbf Z$-scheme into locally closed affine subschemes shows $(1) \Rightarrow (2)$. Note that Lemma 2 implies $(3) \Rightarrow (4)$, but we don't need this. The converse follows from Lemma 1.
It remains to show $(2) \Rightarrow (4)$, where we may assume $A$ is an integral domain. Let $K$ be the algebraic closure of $\mathbf Q$ in $\operatorname{Frac}(A)$. Then $A \otimes \mathbf Q$ is a geometrically integral $K$-algebra [Tags 020I, 037P, and 054Q]. There is a finite set of primes $T$ of $K$ such that $A[1/T]$ is a flat $\mathcal O_{K,T}$-algebra with geometrically integral fibres [EGA IV$_3$, Prop. 8.9.4 and Thm. 9.7.7]. The Lang–Weil bound (or more precise versions coming from the Weil conjectures as proven by Deligne) then gives $$\lvert A(\kappa(\mathfrak p))\rvert \geq \lvert\kappa(\mathfrak p)\rvert^d - c \lvert\kappa(\mathfrak p)\rvert^{d-\tfrac{1}{2}}$$ for all prime ideals $\mathfrak p \subseteq \mathcal O_{K,T}$ and some $c > 0$ that does not depend on $\mathfrak p$. In particular, for all but finitely many primes $\mathfrak p \subseteq \mathcal O_{K,T}$, we get $A(\kappa(\mathfrak p)) \neq \varnothing$. Therefore, for all but finitely primes $p \in \Omega$, we get $A(\mathbf F_p) \neq \varnothing$ if and only if $\mathcal O_{K,T}$ has a prime with residue field $\mathbf F_p$, i.e. if and only if $\mathcal O_{K,T}(\mathbf F_p) \neq \varnothing$. In other words, $S_A \sim S_{\mathcal O_{K,T}}$.
Thus we may replace $A$ by $\mathcal O_{K,T}$, and now we proceed as in Lemma 2: if $f \in \mathbf Z[x]$ is a monic polynomial such that $K \cong \mathbf Q[x]/(f)$, then $A$ and $\mathbf Z[x]/(f)$ differ in finitely many closed fibres, so $S_A \sim S_f$. $\square$
Here's a sketch of an answer. I think the answer is that you can get three types of sets: (i) finite sets, (ii) co-finite sets, and (iii) sets of the form $$ S_f = \{ p : f(x) ~ \textrm{has a root in $\mathbb{F}_p$}\} - S_0 $$ for some polynomial $f \in \mathbb{Z}[X]$, and a finite set of primes $S_0$. By the Chebotarev density theorem, the sets $S_f$ have a density, which is a non-zero rational number.
What this really means is that you can get all sets $P$ already by considering rings of the form $\mathbb{Z}[1/N][X]/(f)$, where $N \geq 1$ is an integer and $f \in \mathbb{Z}[X]$ is a polynomial, which maybe shouldn't be so surprising.
I'm rusty on the technical side of these things, so I might be wrong, but I don't think so.
Case (i): if the characteristic of $A$ is positive, then $\operatorname{Hom}(A,\mathbb{F}_p)=\emptyset$ for all but finitely many $p$.
So we may assume that $\operatorname{char}(A)=0$. Now let $R \subset A$ be the subring consisting of elements that are algebraic over $\mathbb{Z}$.
Case (ii): $R$ is a subring of $\mathbb{Q}$. Then I claim that $\operatorname{Hom}(A,\mathbb{F}_p)=\emptyset$ for only finitely many $p$. Indeed, let $A'$ be a quotient of $A$ corresponding to an irreducible component of $\operatorname{Spec}(A)$, then $A' \otimes_{\mathbb{Z}} \mathbb{Q}$ is the affine coordinate ring of a variety $V$ over $\mathbb{Q}$, which I think is guaranteed to be geometrically irreducible by the fact that $R$ does not contain any irrational algebraic elements. But then, by the Lang-Weil bounds, this variety $V$ will have points over $\mathbb{F}_p$ for sufficiently large $p$. Hence certainly $\operatorname{Hom}(A,\mathbb{F}_p) \neq \emptyset$ for all but finitely many $p$.
Case (iii): $R$ contains non-rational algebraic elements. This means that every $p$ for which $\operatorname{Hom}(A,\mathbb{F}_p) \neq \emptyset$ must be a prime which splits in $R$ into at least one prime with residue class degree $1$. By Chebotarev, the set $S$ of these primes has a density $\delta$ with $0 < \delta < 1$. Since the irreducible components of $A_{R} = \operatorname{Spec}(A) \otimes R$ are (again to the best of my knowledge) geometrically irreducible as $R$-schemes, we can repeat the argument from case (ii) to show that, for $p$ in $S$ sufficiently large, these irreducible components of $A_{R}$ have points over $\mathbb{F}_p$, which in turn implies that for all but finitely many $p$ in $S$ we have $\operatorname{Hom}(A,\mathbb{F}_p) \neq \emptyset$.