I am going to follow the method suggested by **Jason Starr**. Unfortunately, I reach a dead-end in the proof, hopefully one of you can help me fix it.

Note: I modified the universal property that we want. Because I want to be consistent with Hartshorne Exercise 2.5.17.

Let $(Y,\mathcal{O}_Y)$ be a scheme with $\mathscr{A}$ a quasi-coherent sheaf of $\mathcal{O}_Y$-algebras. We denote by $\text{spec } \mathscr{A}$ to be a scheme $X$, for which we have a scheme morphism $f:X\to Y$, and a collection of isomorphisms $\theta_V:f^{-1}V \to \text{spec }\mathscr{A}(V)$ for each open affine $V$ in $Y$, such that if $V\subseteq U$ then the following diagram commutes,
$$\require{AMScd}
\begin{CD} f^{-1} V @>>> f^{-1} U \\
@V\theta_{V} VV @VV \theta_U V \\
\text{spec } \mathscr{A}(V) @>>> \text{spec } \mathscr{A}(U) \end{CD} $$
Furthermore, we require $X$ to have the following universal property. If $Z$ is any scheme for which we have a morphism $g:Z\to Y$, and a natural collection of isomorphisms $\zeta_V:g^{-1}V\to \text{spec } \mathscr{A}(V)$, then there exists a unique morphism $h:Z\to X$ such that $g = f\circ h$ and such that $\zeta_V = \theta_V\circ h_V$ (in the second equation, $h$ is being restricted to $h_V:g^{-1}V \to f^{-1}V$).

Clearly, by abstract non-sense if $X$ exists it is unique, so the question remains that of existence. We first focus on the case when $Y$ is an affine scheme, so $Y = (\text{spec } A, \widetilde{A})$ for some ring $A$. The quasicoherent sheaf $\mathscr{A}$ is then of the form $\mathscr{A} = \widetilde{B}$ for some algebra $B$ over $A$, say given the ring homomorphism $f':A\to B$. Thus, one obtains a scheme morphism $f:\text{spec } B \to \text{spec } A$, and we claim that $\text{spec } B$ will satisfy the required universal property above. One now has to define a natural family of isomorphisms $\theta_V: f^{-1}V\to \text{spec } \mathscr{A}(V)$ for each affine open set $V$ in $Y=\text{spec } A$. First say $V = D(a)$, a basic open set in $Y$, for some $a\in A$. Then $f^{-1}V = D(f'(a))$ a basic open set in $X$. Now $\mathscr{A}(V) = \widetilde{B}(D(a)) = B_a$. A simple algebra exercise will show that the localization $B_a = B_{f'(a)}$. Hence, we need a natural isomorphism $\theta_{D(a)}: D(f'(a)) \to \text{spec } B_{f'(a)}$, which we certainly have (from applying spec to the localization map $B\to B_{f'(a)}$, cf. Exercise 2.1.).

Here is the nice thing about our family $\theta_V$, $V$ basic open, of isomorphisms so far. They are compatible with restriction. That is to say, if $V\subseteq U$ are basic open sets, then the required commutative diagram will be satisfied. But how do we construct the isomorphism $\theta_V$ when $V$ is a more complicated affine set? One invokes the following Lemma which is left unproved as an exercise.

Lemma. Let $f:X\to Y$ be a continuous map of schemes. Let $V_i$ be a collection of open sets which covers a scheme $Y$. For each $i$ we have a scheme (iso)morphism $(f,\theta_i):f^{-1}V_i \to V_i$, where the topological map is given by $f$, and $\theta_i$ is a morphism of structure sheaves
. These (iso)morphisms satisfy: if $V_i\subseteq V_j$ then the dia. com.,
$$ \begin{CD} \mathcal{O}_Y(V_j) @>>> \mathcal{O}_Y(V_i) \\
@V\theta_j VV @VV \theta_i V \\
\mathcal{O}_X(f^{-1}V_j) @>>> \mathcal{O}_X(f^{-1}V_i) \end{CD}$$
Under these hypothesis there exists an (iso)morphism $(f,\theta):X\to Y$. Furthermore, this (iso)morphism is also compatible with restriction.

Now to see why $X$ satisfies the required universal property. Let $h:Z\to Y$ be a scheme for which we have a natural collection of isomorphisms $\zeta_V:h^{-1}V\to \text{spec } \mathscr{A}(V)$. By choosing $V=Y$ we obtain an isomorphism $\zeta_Y:Z\to \text{spec } B$. Call $h=\zeta_Y$. We check that $h$ satisfies $g = f\circ h$ and $\zeta_V = \theta_V\circ h_V$. By choosing $V=Y$, $h_Y = h$ and $\theta_Y = \text{id}$, so we get $\zeta_Y = \text{id}\circ h$ which is true since we defined $h = \zeta_Y$. Therefore, one has to only verify the condition $\zeta_V = \theta_V\circ h_V$.

By using $V\subseteq Y$, where $V$ is any affine open in $Y$, we get a com. dia.,

$$ \begin{CD} g^{-1} V @>i>> Z \\
@V\zeta_{V} VV @V V h V \\
\text{spec }\mathscr{A}(V) @>>> X \\
@V\theta_{V}^{-1} VV @VV\text{id}V \\
f^{-1}V @>>j> X \end{CD} $$
From this diagram we see that $\theta_V^{-1}\circ \zeta_V:g^{-1}V\to f^{-1}V$ and $h_V:g^{-1}V\to f^{-1}V$ are equal. Thus, we obtain $\zeta_V = \theta_V\circ h_V$ as required.

Thus, $\text{spec } \mathscr{A}$ exists in the case when $Y$ is an affine scheme and it is given by $\text{spec } B$. For the next part of the proof we show that if $Y$ is a scheme with a quasi-coherent sheaf $\mathscr{A}$ of $\mathcal{O}_Y$-algebras, and $U$ is an open subset of $Y$, then $\text{spec } \mathscr{A}|_U$ exists when we restrict the sheaf $\mathscr{A}$ to the scheme $U$. In fact, if $f:X\to Y$ is our universal map where $X=\text{spec }\mathscr{A}$, then $f^{-1}U = \text{spec } \mathscr{A}|_U$. Since $X = \text{spec } \mathscr{A}$, for each affine open set $V$ in $Y$, we have a natural collection of isomorphisms $\theta_V: f^{-1}V\to \text{spec } \mathscr{A}(V)$. By choosing those affine open sets contained in $U$, the collection $\{ \theta_V \}|_{V\subseteq U}$ is a natural collection, for the scheme $U$ with quasicoherent $\mathcal{O}_Y|_U$-algebra given by $\mathscr{A}|_U$.

One has a scheme morphism $f^{-1}U\to U$ given by restriction called $f_U$, and the natural collection $\{ \theta_V \}|_{V\subseteq U}$. We will show that these two satisfy the universal property for $\text{spec } \mathscr{A}|_U$. We suppose that there is a scheme $S$ together with a morphism $g:S\to U$ and a natural collection of isomorphism $\sigma_V:g^{-1}V\to \text{spec } \mathscr{A}(V)$, for every open affine $V$ contained in $U$. We seek to exhibit a morphism $h:S\to f^{-1}U$, such that $g = f_U\circ h$ and $\sigma_V = \theta_V \circ h_V$.

Here are the problems.
(i) How do I complete the proof that $f^{-1}U$ is the relative spec of $\mathscr{A}|_U$?
(ii) It seems in my approach I require the assumption that $Y$ is separated?