In this thread
Why must nilpotent elements be allowed in modern algebraic geometry?
you find the following construction: Let $k$ be a field or the ring $\mathbb{Z}$ of integers and let $X$ be a scheme of finite type over $k$. By this we mean $X$ has a finite open affine cover $X=\cup_{i=1}^n Spec(A_i)$ where $A_i$ is a finitely generated $k$-algebra for all $i$.
Definition 1. Let $X^m$ be the set of closed points in $X$ with $u:X^m \rightarrow X$ the canonical inclusion map and with the induced topology. Let $\mathcal{O}_{X^m}:=u^{-1}(\mathcal{O}_{X})$ be the topological inverse of $\mathcal{O}_X$.
There is the following Lemma:
Lemma 1. Let $\phi: A\rightarrow B$ be a map of finitely generated $k$-algebras
where $k$ is a field or the ring of integers. If $\mathfrak{m}\subseteq B$ is a maximal ideal it follows $\mathfrak{n}:=\phi^{-1}(\mathfrak{m})\subseteq A$ is a maximal ideal.
Lemma 1 remains true if $A,B$ are essentially of finite type over $k$, since the maximal ideals in a localization $S^{-1}B$ are in 1-1 correspondence with maximal ideals in $B$ that do not meet $S$. Hence the definition and Lemma 1 makes sense for any local ring $B_{\mathfrak{p}}\cong S^{-1}B$ where $S:=B-\mathfrak{p}$.
Hence the classical map $\phi^*: Spec(B)\rightarrow Spec(A)$ induced by the map of rings $\phi: A\rightarrow B$, induce a map
$$ \phi(m): Spec(B)^m\rightarrow Spec(A)^m$$
which is continuous in the topology induced from the Zariski topology on $S:=Spec(A)$ and $X:=Spec(B)$. The map of structure sheaves
$$\phi^{\#}: \mathcal{O}_S \rightarrow \phi_*\mathcal{O}_X$$
induce a map
$$\phi(m)^{\#}: \mathcal{O}_{S^m}\rightarrow \phi(m)_*(\mathcal{O}_{X^m}).$$
Hence we get from the map $\phi: A\rightarrow B$ a map of locally ringed spaces
$$(\phi(m),\phi(m)^{\#}):(X^m, \mathcal{O}_{X^m})\rightarrow (S^m, \mathcal{O}_{S^m}).$$
It follows we may associate to a finitely generated $k$-algebra $B$ the pair $(X^m, \mathcal{O}_{X^m})$ which is a locally ringed space. This construction is functorial and we get a functor
$$F: \underline{Alg^f(k)} \rightarrow \underline{RSpace}$$
where $\underline{Alg^f(k)}$ is the category of commutative unital $k$-algebras that are fintely generated over $k$ and $\underline{RSpace}$ is the category of locally ringed spaces. When we pass to global sections we recover the original map $\phi$. If we require a map of locally ringed space to be "local" it seems the following holds:
$$Hom_{Rings}(A,B) \cong Hom_{RSpace}((X^m,\mathcal{O}_{X^m}), (S^m, \mathcal{O}_{S^m}))$$
Hence using the functor $F$ we get an embedding of the category $\underline{Alg^f(k)}$ as a sub category of the category of locally ringed spaces - we may view $F$ as a "geometrization functor". If $\phi$ is a morphism in $\underline{Alg^f(k)}$, it follows $F(\phi)$ is an isomorphism iff $\phi$ is an isomorphism.
Example. The ringed space $(X^m, \mathcal{O}_{X^m})$ is a "compromise" between a "classical algebraic variety" and a "scheme" - it is more intuitive and you can speak about nilpotent elements in the structure sheaf. If $I \subseteq A$ is an ideal and $X:=Spec(A/I), X(n):=Spec(A/I^{n+1})$, it follows
$X^m$ and $X(n)^m$ are isomorphic as locally ringed spaces iff $n=0$. The underlying topoplogical spaces are isomorphic since a maximal ideal $\mathfrak{m}\subseteq A$ contains $I$ iff it contains $I^{n+1}$.
Lemma 2. If $X^m:=Spec(B)^m$ and $\mathfrak{m}\in X^m$ is a point it follows
$$ \mathcal{O}_{X^m,\mathfrak{m}}\cong \mathcal{O}_{X,\mathfrak{m}}$$
Proof: There is the embedding $u: X^m \rightarrow X$ and by definition
$$\mathcal{O}_{X^m,\mathfrak{m}}:=lim_{\mathfrak{m}\in U^m}u^{-1}(\mathcal{O}_X)(U^m) \cong $$
$$ lim_{\mathfrak{m}\in U}\mathcal{O}_X(U) \cong \mathcal{O}_{X,\mathfrak{m}}.$$ QED
Hence the sheaves $\mathcal{O}_{X^m}$ and $\mathcal{O}_X$ have the same stalks at maximal ideals.
Example. If $(A,\mathfrak{m})$ is a local ring and $X^m:=Spec(A)^m$, you get
$$\mathcal{O}_{X^m}(X^m) \cong A \cong A_{\mathfrak{m}}\cong \mathcal{O}_{X^m,\mathfrak{m}}$$
since $A$ is local and the multiplicative set $S:=A-\mathfrak{m}$ consists of units. Hence when you localize $A$ at $S$ you recover $A$. The topological space $X^m$ is the one point space, but the information on the "subvarieties" through the point $\mathfrak{m}$ is encoded in the structure sheaf: It is the set of prime ideals in the ring of global sections of the structure sheaf. Hence the information on these subvarieties is not lost when passing to the ringed space $X^m$.
In the above thread I explain why $X^m$ is a locally ringed space that is "similar" to a "classical algebraic variety" as defined in Hartshornes book in chapter I as the set of zeros of an ideal in a polynomial ring in a finite set of variables. The difference is that Hartshorne starts with a fixed algebraically closed field $k$ and an ideal $I:=\{f_1,..,f_n\} \subseteq B:=k[x_1,..,x_n]$ in a polynomial ring $B$ in a finite set of variables.
Example: Hartshorne defines $V(I)$ as the "set of $n$-tuples" $\{t:=(t_1,..,t_n)\in k^n\}$ such that $f(t_1,..,t_n)=0$ for all poynomials in $I$. Hence Hartshornes $n$-tuples $t$ have their coefficients in the base field $k$. Since the field $k$ is algebraically closed it follows the set of maximal ideals $\mathfrak{m}$ in $X^m$ all have residue field $k$. Hence for an algebraically closed field $k$ it follows $X^m=V(I)$ if $X:=Spec(A)$ and $A:=B/I$. The above Definition 1 makes sense for any Hilbert-Jacobson ring $k$. You need the property that any prime ideal $\mathfrak{p}$ in $k$ is the intersection of maximal ideals.
Example. Let $A:=\mathbb{R}[x]$ and let $C:=Spec(A)$. It follows $C^m$ is the set of irreducible polynomials in $A$. A polynomial $p(x)$ in $A$ is irreducible iff $p(x)=x-r$ with $r\in \mathbb{R}$ or $p(x)=(x-z)(x-\overline{z})=x^2-4ax+a^2+b^2$ with $a,b\in \mathbb{R}$ and $b \ne 0$. In the above thread I explain how you may use nilpotent elements to Taylor expand sections of $\mathcal{O}_{C^m}(U)$. To explain Taylor expansion for sections of sheaves to students using real curves is "easier to understand" and "more intuitive". Sometimes students have problems understanding the field of complex numbers.
The structure sheaf $\mathcal{O}_{X^m}$ has the property
P1. $\Gamma(X^m, \mathcal{O}_{X^m})=i^{-1}(\mathcal{O}_X)(X^m):=lim_{X^m \subseteq U}\mathcal{O}_X(U) \cong \Gamma(X, \mathcal{O}_X)$,
hence $\mathcal{O}_{X^m}$ and $\mathcal{O}_X$ have the same global sections. Hence if $X:=Spec(A)$ it follows $\Gamma(X^m, \mathcal{O}_{X^m})=A$ and you recover the ring $A$ from the locally ringed space $(X^m, \mathcal{O}_{X^m})$.
Example: If $S:=A[x_1,..,x_n]/I$ where $I$ is a homogeneous ideal and $A$ is a Hilbert-Jacobson ring we may define $X^m \subseteq X:=Proj(S)$. If $\mathcal{E}$ is any finite rank locally trivial $\mathcal{O}_X$-module, we may define $\mathbb{P}(\mathcal{E}^*)^m \subseteq \mathbb{P}(\mathcal{E}^*)$.
If $I \subseteq A\otimes A$ is the ideal of the diagonal and if
$\mathcal{P}(l):=Spec(A\otimes A/I^{l+1})$
we may define $\mathcal{P}(l)^m$. It has the property that
$\Gamma(\mathcal{P}(l), \mathcal{O}_{\mathcal{P}(l)})=A\otimes A/I^{l+1}$.
The canonical surjective map $m: A\otimes A/I^{l+1} \rightarrow A$ gives a one-to-one correspondence between $\mathcal{P}(l)^m$ and $Spec(A)^m$. Hence $\mathcal{P}(l)^m$ has the same points as $Spec(A)^m$ but it has non-trivial nilpotent elements in the structure sheaf - it is a "classical algebraic variety" with a non-reduced structure sheaf.
Comment: "Of course, there are some problems with this approach: The class of all fields is not a set. Technically, we can limit ourselves to some very large set of "test fields". So this can be swept under the rug."
Remark: The ring $A$ can be an arbitrary finitely generated $k$-algebra and it can be non-reduced. Hence this gives a way of introducing nilpotent elements for "classical algebraic varieties" without speaking about "classes of fields". Since $X^m$ is defined as the "set of closed points" in the "set" $X$, there are no "set theoretic difficulties" and if you want to teach algebraic geometry to students you want to avoid this. Moreover you don't use prime ideals, hence the construction gives an answer to the original question: Yes you may do this if the base ring is a finitely generated ring over a field or the integers $\mathbb{Z}$.