Note: This answer takes the definition of a metric basis as an inclusion-minimal metric generating set as opposed to one that has minimal cardinality. This definition is non-standard. ThisAnother answer deals with the same topics but takes the latterstandard view of metric bases as cardinality-minimal metric generating sets.
First I'll characterize those finite metric spaces with well-defined metric dimension in terms of the purity of a related simplicial complex and then briefly talk about how matroids fit into the picture.
Simplicial Complex Background
We will need some terminology for (abstract) simplicial complexes. A simplicial complex on a set $S$ is a collection of subsets $\Delta$ of $S$ that is closed under taking subsets, that is, if $T \in \Delta$ and $T' \subseteq T$, then $T' \in \Delta$. The elements of $\Delta$ are called its faces and the inclusion-maximal faces are the facets of $\Delta$. The rank of a face $F$ is given by $r(F)=\#F$ and the rank of $\Delta$, denoted $r(\Delta)$, is the largest rank of a face in $\Delta$.
Note that for a general simplicial complex, the cardinality of two facets need not be equal. (Example: $([3], \{\emptyset, 1, 2, 3, 23\})$.) However, if all facets do have the same cardinality the simplicial complex is called pure.
A (nearly trivial) characterization
Let $(M,d)$ be a finite metric space and let $\mathcal{G}$ be the collection of all generating sets for $(M,d)$. Define the set
$$\Delta = \Delta(M,d) := \{M \setminus G~|~G \in \mathcal{G}\}.$$
Note that if $G' \supseteq G$ and $G \in \mathcal{G}$ then $G' \in \mathcal{G}$. This impies that the set $\Delta$ is an abstract simplicial complex on $M$. The facets of $\Delta$ correspond to cardinality-minimalinclusion-minimal generating sets of $(M,d)$ by set complementation. So the metric dimension of the finite metric space $(M,d)$ is well-defined (using this nonstandard definition) if and only if the complex $\Delta(M,d)$ is pure. In this case, $\dim(M,d) = \#M - r(\Delta)$.
Matroids
Now let me try to tie this into the matroid discussion in Example 1 of this answer to the previous question. In that example we have $M = \{0,1,2,3\}$ and $d$ given by
$$d(x,y) = \begin{cases} 2 \text{ if } x,y \neq 0 \\ 2 + \frac{1}{y} \text{ if } x = 0. \end{cases}$$
One computes that $\mathcal{G}$ isthe metric generating sets consist of all subsets of $\{0,1,2,3\}$ except for the empty set and the singletons $\{i\}$ where $i \in [3]$. So $\Delta(M,d)$ is the simplicial complex
consisting of all subsets of {0,1,2,3} that do not contain 0
whose faces are arranged by containment in the following poset. So $\Delta(M,d)$ is not pure (it has three facets of rank two and a facet of rank three) and so the metric dimension for(using this nonstandard definition) of $\Delta(M,d)$ is not well-defined.
$Delta(M,d)$" />
Let us note that using the standard definition of metric dimension $(M,d)$ has metric dimension one since its only metric basis is $\{0\}$; see this answer to this post for more on the standard case.
For an arbitrary finite metric space $(M,d)$, the complex $\Delta(M,d)$ is a matroid (that is, its facets satisfy the basis exchange axiom for matroids) if and only if the "matroid dual" complex
$$\Delta^*(M,d) := \{H \subseteq G | G \text{ is inclusion-minimal in } \mathcal{G}\}$$
is a matroid. In this case the metric dimension of $(M,d)$ is just the rank of $\Delta^*(M,d)$.