Necessity of the use of reals in the metric definition A metric $d$ is a function $d:X \times X \to \mathbb{R}$ such that $d(x,y)\geq 0$ and equals $0$ iff $x=y$. $d(x,y)=d(y,x)$ and the triangle inequality holds. From these requirements, the only things that are used is that the codomain has a $0$, a $+$ operation and a linear order. So, it seems, we could in principle define a metric by a function $d: X \times X \to G$ such the same expressions hold, and where $G$ is an ordered group.
My question is, what usual theorems do we lose by picking that definition? In particular, some key questions come to mind

*

*If there is a metric on a space $X$, when allowing for other groups in the codomain, does that imply there is a metric with codomain $\mathbb{R}$? That is, does the collection of metrizable spaces expand with the new definition?

*A kind of converse to the previous one, for any infinite ordered group $G$, if there is metric with codomain $\mathbb R$, is there necessarily one with codomain $G$ that generates the same topology? (it being infinite is necessary as the trivial group satisfies all the metric properties but always generates the discrete topology).

 A: The "ultimate generalisation" of such an idea (it's old) is due to Kopperman all topologies come from generalised metrics (Amer. Math. Monthly (95) 1988, nr 2, 89-97). I saw his talk on this around that time...
He considers a semigroup $A$ (so just an associative binary operation) with identity $0$ and $\infty \neq 0$ an absorbing element and calls it a value semigroup if

*

*If $a+x=b$ and $b+y=a$, then $a=b$. In that case $a \le b$ iff $\exists x: a+x=b$ defines a partial order on $A$.

*For each $b$ there is a unique $a$ so that $b+b =a$ (and we write $b = \frac12 a$).

*For all $a,b$, $a \land b = \inf\{a,b\}$ exists.

*For all $a,b,c$ we have $(a \land b) + c = (a+c) \land (b+c)$.

A set $P \subseteq A$, where $A$ is a value semigroup, is called a
set of positives if

*

*$a,b \in P \to a \land b \in P$.

*$r \le a$ and $r \in P$ implies $a \in P$.

*if $r \in P$ then $\frac12 r \in P$ as well.

*if $a \le b+r$ for each $r \in P$, then $a \le b$.

Finally, if $X$ is a set, $A$ is a value semi-group, $P \subseteq A$ a set of positives, and $d: X \times X \to A$ a function that obeys $d(x,x)=0$ for all $x$ and $d(x,z) \le d(x,y) + d(y,z)$ for all $x,y,z \in X$, then $(X,A,P,d)$ is called a "continuity space".
For $x \in X, r \in P$ we define $B[x,r] = \{y \in X: d(x,y) \le r\}$ and then $\mathcal{T} = \{O \subset X\mid \forall x \in O: \exists r \in P: B[x,r]\subseteq O\}$ defines a topology on $X$ and (Kopperman's theorem) every topology on $X$ is of this form.
A: Kopperman's approach was already mentioned in the answers. There is also Flagg's "Quantales and continuity spaces" (alg. univ., 1997). Flagg uses a value quantale as the codomain of the metric. The two approaches are quite different. A main technical difference is that Kopperman's value semigroups require specifying the collection of elements that act as the positive elements. Flagg's value quantales come equipped with a notion of being positive (i.e., well above the bottom element).
Both approaches yield the theorem: For all topological spaces $(X,\tau )$ there is a value semigroup/quantale and a metrisation of $X$ whose induced open ball topology is $\tau$, and in fact a functor $\mathcal O$ from the suitably defined category of generalised metric spaces and continuous functions, to the usual category of topological spaces. But only in Flagg's formalism this functor $\mathcal O$ is an equivalence of categories ("A note on the metrizability of spaces", alg. univ., 2015).
A survey of what happens when one does topology along this functor can be found in "The topology of a quantale valued metric space", FSS, 2020). Perhaps interesting is the theorem that in that formalism not only is there an equivalence between usual topology and this category of metric spaces, but in fact the open ball topology functor is the unique equivalence between these categories, when these are considered as concrete over $\mathbf {Set}$. This is a way to see that the usual open ball topology construction is not ad-hoc.
A: Changing the codomain of a metric-like function - which I'll call a "generalized metric" - can indeed drastically change the situation.
Re: your first question, consider any ordered group $G$ in which the identity has uncountable cofinality - that is, for every countable set of positive elements $X$ there is some positive element less than every element of $X$. $G$ with the order topology is generalized metrizable with "distance group" $G$ itself (use the absolute value map) but cannot be metrizable in the usual sense (otherwise think about picking a positive $\alpha_i$ within $2^{-i}$ of the identity).
(Offhand I don't know a particularly simple example of such a $G$, but they do exist - for example, take an ultrapower $(\mathbb{R},+)^\mathbb{N}/U$ for $U$ a nonprincipal ultrafilter on $\mathbb{N}$.)
Re: your second question, take $\mathbb{R}$ with the usual topology. I claim that there is no generalized metric on $\mathbb{R}$ with codomain $\mathbb{Q}$ which generates the usual topology on $\mathbb{R}$. This is because $\mathbb{Q}$ is totally disconnected but $\mathbb{R}$ is connected: given a map $d:\mathbb{R}^2\rightarrow\mathbb{Q}$, consider e.g. $\{x\in\mathbb{R}: d(x,0)<\alpha\}$ for a sufficiently small positive irrational $\alpha$.
Meanwhile, note that since every ordered group embeds into the surreal numbers, the generalized metrizable spaces are exactly the "surreally metrizable" spaces.
