Localic or topos-theoretic definition of $\operatorname{Spec}$ Usually, the construction of the spectrum of a commutative ring starts with defining the points of $\operatorname{Spec}(A)$, and constructing a topology with the closed sets being the "zeroes" of elements of $A$, and the sets $D(f)$ being a basis of opens. The fact that $D(I) = D(\sqrt{I})$ is then a theorem.
Is there a construction of the spectrum of a ring, where it is defined as a locale or Grothendieck site generated by the $D(f)$, and where the relation that $D(f^k) = D(f)$ is definitional ?
 A: 
Is there a construction of the spectrum of a ring, where it is defined as a locale or Grothendieck site generated by the D(f), and where the relation that D(fk)=D(f) is definitional?

Yes, the Zariski spectrum of a commutative ring is the locale whose frame is precisely the poset of radical ideals.  Infima in this poset are given by intersections and suprema are given by taking the radical ideal generated by the union.  An elementary argument then proves the distributivity property of frames.
This construction satisfies all of the original requirements essentially by definition.
Since the resulting locale is a coherent locale, it is spatial in the presence of the axiom of choice, which allows one to recover the point-set Zariski spectrum from it.
A: You might be interested in Cole's theory of spectrum. Besides the references given on that nlab page (which include several related theoretical frameworks, such as Lurie's theory of structured infinity-topoi), another good reference is Axel Osmond's thesis.
In brief, the idea is something like the following. If $\mathcal B$ is a topos (e.g. $\mathcal B = BCRing = [CRing^{fp},Set]$, the classifying topos for commutative ring objects), one seeks to identify additional structure to define the category of "locally $\mathcal B$-structured topoi" (in our example, the additional structure picks out those commutative ring objects which are local, and those maps of ringed topoi which are local). Then one sets up a contravariant adjunction between points of $\mathcal B$ and locally $\mathcal B$-structured topoi (the functor from the former to the latter is the Spectrum construction in our example).
One nice thing about this sort of framework is that it also includes the example of the étale spectrum of a ring, by changing the additional data determining what it means to be "locally $\mathcal B$-structured".
A: The Zariski spectrum is essentially the classifying topos for prime ideal of $A$, or to be more precise, the classifying topos for subsets of $A$ that are "complement of prime ideals of $A$". The precise geometric theory is given by:
$$x+y \in U \Rightarrow x \in U \text{ or } y \in U$$
$$xy \in U \Leftrightarrow x \in U \text{ and } y \in U$$
$$ 1 \in U$$
$$ 0 \notin U$$
where the $x \in U$ are the basic proposition of the theory (and $U$ represents this "subset of $A$ which is the complement of a prime ideals").
This can be immediately translated into the fact that that (the frame corresponding to) the Zariski spectrum is the frame freely generated by the symbols $D(a)$ for $a \in A$ subject to the relations:
$$D(x+y) \leqslant D(x) \cup D(y)$$
$$D(xy)= D(x) \cap D(y)$$
$$D(1) = \top$$
$$D(0) = \bot$$
You can rewrite this as a site if you want - but generally, the presentation as a free locale is more convenient. Of course, the relation $D(f^n)=D(f)$ immediately follow from the second condition.
The structure sheaf of the Zariski spectrum can easily be obtained form this as well: internally in the topos of sheaf over the Zariski spectrum, you have the generic such subsheaf $U \subset A$ (where $A$ is the constant sheaf). The Structure sheaf is $A[U^{-1}]$.
Note that this definitely appears in a few places in the literature. But I'm not sure what is the appropriate reference to attribute it to. My Guess is Johnstone's Stone Space, but I can't check it right now.Edit: as comfirmed by Zhen Lin in the comment this appears in Johnstone's Stone Space, where it is attributed to Joyal without reference.
A: This is ultimately the same construction as the one Simon Henry describes, but you might like the different perspective.
Definition.
Let $A$ be a commutative rig and let $L$ be a distributive lattice.
A support notion $\lambda : A \to L$ is a map with the following properties:

*

*$\lambda (0)$ is the bottom element of $L$ and $\lambda (a + b) \le \lambda (a) \lor \lambda (b)$.

*$\lambda (1)$ is the top element of $L$ and $\lambda (a b) = \lambda (a) \land \lambda (b)$.

Joyal defined the order-theoretically dual notion in [1975, Les théorèmes de Chevalley-Tarski et remarques sur l'algèbre constructive] under the name notion of zeros.
Wraith [1979, Generic Galois theory of local rings] defines support notions as above.
Let $\textrm{Supp} (A, L)$ be the set of support notions $A \to L$.
It is clear that it is covariantly functorial in $L$ and contravariantly functorial in $A$.
In fact:
Proposition.
For each commutative rig $A$, the functor $\textrm{Supp} (A, -) : \textbf{DLat} \to \textbf{Set}$ is representable.
The representing object is the distributive lattice $A_\mathrm{D}$ generated by symbols $\mathrm{D} (a)$ ($a \in A$) subject to the relations making the map $a \mapsto \mathrm{D} (a)$ a support notion.
Thus, we obtain a functor $\textbf{CRig} \to \textbf{DLat}$ sending $A$ to $A_\mathrm{D}$.
Recall that every distributive lattice is a commutative rig with $\lor$ as addition and $\land$ as multiplication;
then note that if $A$ is a distributive lattice then $\mathrm{D} : A \to A_\mathrm{D}$ is an isomorphism.
(It is tempting to imagine that $A \mapsto A_\mathrm{D}$ is the left adjoint to the inclusion $\textbf{DLat} \hookrightarrow \textbf{CRig}$, but it is not.)
We can obtain a slightly more explicit characterisation of $A_\mathrm{D}$.
Lemma.
Let $a \in A$ and $\{ b_1, \ldots, b_n \} \subseteq A$.
Then $\mathrm{D} (a) \le \mathrm{D} (b_1) \lor \cdots \lor \mathrm{D} (b_n)$ in $A_\mathrm{D}$ if and only if there exist $c_1, \ldots c_n$ and $m$ such that $b_1 c_1 + \cdots + b_n c_n = a^m$.
It now follows that:
Proposition.
$A_\mathrm{D}$ is isomorphic to the lattice of finitely generated radical ideals of $A$.
In particular, when $A$ is a ring, $A_\mathrm{D}$ is isomorphic to the lattice of quasicompact open subsets of the Zariski spectrum of $A$.
Of course, we could do all this with frames instead of distributive lattices, but then we would not have the tantalising mystery of how $A \mapsto A_\mathrm{D}$ is (isomorphic to) the identity functor on $\textbf{DLat}$.
One could also imagine categorifying this to obtain the topos $\textbf{Sh} (\operatorname{Spec} A)$ from the symmetric monoidal abelian category $\textbf{Mod} (A)$, but I haven't figured out how yet.
