How can dimension depend on the point?
Lars Olsen [1], [2] (2005, 2005) has proved some results about this notion. Let $E \subseteq {\mathbb R}^{n}$ and $x \in {\mathbb R}^{n},$ where $n$ is a fixed positive integer. Let $\dim_{H}(E,x)$ and $\dim_{P}(E,x)$ denote the local Hausdorff and local packing dimensions of $E$ at $x,$ defined as in your question.
Discussion of Results in Olsen [1]
In [1] Olsen proved that, given any continuous function $f:{\mathbb R}^n \rightarrow [0,n],$ there exists $E \subseteq {\mathbb R}^{n}$ such that for all $x \in {\mathbb R}^{n}$ we have $f(x) = \dim_{H}(E,x) = \dim_{P}(E,x).$
Olsen observed (p. 214) that it is easy to see that some local dimension functions can be discontinuous, giving the example $f:{\mathbb R} \rightarrow [0,1]$ defined by $f(x) = \frac{\ln 2}{\ln 3}$ for $x \in C$ and $f(x) = 0$ if $x \notin C,$ where $C$ is the Cantor middle thirds set. In fact, the characteristic function of a compact interval gives a simpler example, but I suppose Olsen gave the example he did because then the discontinuities occur at every point of the Cantor set.
Olsen also observed (p. 214) that it is easy to see that some very simple discontinuous functions $f:{\mathbb R} \rightarrow [0,1]$ cannot be a local dimension function, giving the example $f(x) = 0$ if $x \neq 0$ and $f(0) = 1.$
Olsen posed the problem (p. 214) of characterizing those functions $f:{\mathbb R}^n \rightarrow [0,n]$ that can be the local dimension function (Hausdorff and/or packing) of some subset of ${\mathbb R}^{n}.$
The result Olsen actually proved was a bit sharper than I stated above. Let $M(f,x,r)$ denote the supremum of $|f(x_{1}) – f(x_{2})|$ as $x_1$ and $x_2$ vary over the open ball $B(x,r)$ of radius $r$ centered at $x.$ Olsen's Theorem 1.1 in [1] states that, given any function $f:{\mathbb R}^n \rightarrow [0,n]$ (continuous or not), there exists $E \subseteq {\mathbb R}^{n}$ such that for all $x \in {\mathbb R}^{n}$ and for all $r > 0$ we have
$$| f(x) \; - \; \dim_{H}\left(E \cap B(x,r) \right)| \;\; \leq \;\; M(f,x,r)$$ $$| f(x) \; - \; \dim_{P}\left(E \cap B(x,r) \right)| \;\; \leq \;\; M(f,x,r)$$
Olsen observed that if $f$ is continuous, then we obtain the result I gave earlier.
Discussion of Results in Olsen [2]
In [2] Olsen provided an answer to the problem he posed in the earlier paper by characterizing those functions $f:{\mathbb R}^n \rightarrow [0,n]$ that can be the local dimension function (in both the Hausdorff and the packing sense) of some subset of ${\mathbb R}^{n}.$
For Hausdorff dimension, the characterization Olsen gave is that $f:{\mathbb R}^n \rightarrow [0,n]$ satisfies:
(1) For each $x \in {\mathbb R}^{n},$ we have $\limsup_{x' \rightarrow x} f(x') = f(x).$
(2) For each $y$ with $0 \leq y < \sup f$ and for each $x \in \{f > y\} \; = \; \{x' \in {\mathbb R}^{n}: \; f(x') > y \},$ we have $\dim_{H}\left( \{f > y\}, \;x\right) \; > \; y.$ Here, "$\sup f$" denotes the supremum of $f$ over ${\mathbb R}^{n}.$
The characterization for packing dimension is identical except that $\dim_{P}$ replaces $\dim_{H}$ in (2).
Before proving this result, Olsen gave an example (2nd example on p. 233) to show that there exist functions $f:{\mathbb R} \rightarrow [0,1]$ satisfying (1) but not satisfying (2). The example Olsen gave is the function $f$ equal to $s$ (a constant) at each point of the Cantor middle thirds set $C$ and equal to $0$ elsewhere, where $\frac{\ln 2}{\ln 3} < s \leq 1.$ To see that (2) does not hold, note that if $y$ is chosen so that $\frac{\ln 2}{\ln 3} \leq y < s,$ then $\{f > y\} = C.$ Incidentally, Olsen uses Hausdorff dimension throughout in this example, but since the packing and Hausdorff dimensions of the Cantor middle thirds set are both equal to $\frac{\ln 2}{\ln 3},$ the same example shows that (1) can hold and (2) can fail for packing dimension as well.
As was the case with Olsen's earlier paper, Olsen actually proved a bit more than I've stated thus far.
Rather than limiting himself to the Hausdorff or packing dimensions, he proved the characterization for the local dimension function of any "regular dimension index", which is an assignment $\dim$ of a non-negative real number to each subset of ${\mathbb R}^{n}$ such that $\dim$ is monotone with respect to set inclusion, $\dim$ is countably stable, $\dim$ assigns the value of $0$ to every finite subset, and $\dim$ is regular in the sense that given any Borel set $E$ and any real number $t$ with $0 \leq t < \dim E,$ then there exists a compact set $K$ such that $K \subseteq E$ and $\dim K = t.$
Also, Olsen proved that the set for which the function is to be a local dimension function of can always be chosen to be an $F_{\sigma}$ set. In a Remark on p. 235 (that Olsen attributes to a referee -- see Acknowledgements at the end of the paper), he shows that $F_{\sigma}$ cannot be strengthened to "closed".
Olsen's punctured upper limit and punctured upper semicontinuous notions
Olsen uses a non-deleted notion of $\limsup$ in which the value of the function is taken into account, and he uses the phrase punctured upper limit for the usual $\limsup$ notion in which the value of the function is not taken into account. For a simple example, if $f(x) = 0$ for $x \neq 0$ and $f(0) = 1,$ then the non-deleted $\limsup$ of $f$ at $x=0$ is $1$ and the delted $\limsup$ of $f$ at $x=0$ is $0.$ For a less simple example, if $T$ is the Thomae function, then at each nonzero rational $x$ the non-deleted $\limsup$ of $T$ is equal to $T(x) \neq 0$ and the deleted $\limsup$ of $T$ is equal to $0.$
In the case of upper semicontinuous, Olsen uses the standard definition in which at each point the value of the function is greater than or equal to the deleted $\limsup$ at that point. However, for his characterization of the local dimension function, Olsen requires a refinement of this, which he calls punctured upper semicontinuous. This is the property in which at each point the value of the function is equal to the deleted $\limsup$ at that point. In my summary above I have avoided this terminology and stated (1) directly in terms of the $\limsup$ operation (deleted version being understood, as that is the standard notion). Incidentally, one sometimes sees the phrase upper boundary function used for functions that satisfy (1).
Finally, if anyone is interested in continuity issues, I believe that any $F_{\sigma}$ first category (in the Baire sense) subset of ${\mathbb R}^{n}$ can be the discontinuity set for a dimension function, but I have not looked at this carefully. I do know that any such set can be the discontinuity set for a function satisfying (1) above. For some possible properties of sets that are $F_{\sigma}$ and first category, see my answer to How discontinuous can a derivative be?.
The less precise result that any such set can be the discontinuity set for an upper semicontinuous function is proved in Proof Sketch at Oscillation of a Function, but I believe the proof there needs to be modified to actually show the result for (1). However, the result for (1) is a consequence of the more precise results proved by Zbigniew Grande in Quelques remarques sur la semi-continuité supérieure [Fundamenta Mathematicae 126 (1985), pp. 1-13] and by Tomasz Natkaniec in On semicontinuity points [Real Analysis Exchange 9 (1983-844), pp. 215-232]. The issue I have not investigated is whether any such set can be the discontinuity set for a function satisfying both (1) and (2) above.
[1] Lars Olsen, Applications of divergence points to local dimension functions of subsets of ${\mathbb R}^{d}$, Proceedings of the Edinburgh Mathematical Society (2) 48 #1 (February 2005), 213-218. MR 2005m:28023; Zbl 1061.28004
[2] Lars Olsen, Characterization of local dimension functions of subsets of ${\mathbb R}^{d}$, Colloquium Mathematicum 103 #2 (2005), pp. 231-239. MR 2006j:28020; Zbl 1105.28007
Given a continuous function $f:\mathbb R\to(1,n+1)$, it is possible to find a closed set $A\subset\mathbb R\times\mathbb R^n=\mathbb R^{n+1}$ so that the projection of $A$ to the first coordinate is surjective and $\dim(x)=f(x_1)$ for all $x\in A$. Here the dimension is the dimension of $A$ at $x\in A$.
I will only sketch a proof for $n=1$ since the proof is more transparent, but the same idea works in any dimension. For any $\gamma\in(0,1)$ we can construct a Cantor set $C_\gamma\subset[0,1]$ by iteratively removing a middle part of relative length $\gamma$ from each interval. (The classical Cantor set corresponds to $\gamma=\frac13$.)
Let $\phi(t)=1-2^{1-1/t}$. The dimension of $C_\gamma$ is $\phi^{-1}(\gamma)$ at every point. Let now $$ A=\{x\in\mathbb R^2;x_2\in I_{\phi(f(x_1))}\}. $$ If we only did a finite number of iterations in the construction of the Cantor sets, $A$ would clearly be closed by continuity of $\phi\circ f$. Our set $A$ is an intersection of such closed sets and thus closed. The dimension of $A\cap\{x_1=a\}$ is $f(a)$.
If $x\in A$, then clearly $$ \inf_{y\in B(x,r)}f(y) \leq \dim(B(x,r)) \leq \sup_{y\in B(x,r)}f(y). $$ Then by continuity of $f$ we have $\dim(x)=f(x_1)$.
Expanding my comment by some observations:
The function $\dim\colon M\to[0,\infty]$ is upper semicontinuous: For every $x \in M$ and $\epsilon >0$ there exists $r > 0$ such that $$\dim(x) > \dim(B(x,r)) - \epsilon.$$ Thus for every $y \in B(x,r)$ we have $$\dim(y) \le \dim(B(y,r-d(x,r))) \le \dim(B(x,r)) < \dim(x) + \epsilon.$$
Not every upper semicontinuous function $f\colon X \to [\dim_{\text{top}},\infty)$ on every metrizable topological space $X$ can be realized as the dimension-function for some compatible distance: Take for example $$f \colon \mathbb{R} \to [1,\infty), x \mapsto \begin{cases}2,& \text{if }x = 0\\ 1,& \text{otherwise}\end{cases}.$$
One way to construct examples is to locally snow-flake the distance. For example, let $f \colon \mathbb{R} \to [1,\infty)$ be a continuous function. For all $x,y \in \mathbb{R}$ define $$d(x,y) = |x-y|^{1/\min_{z\in[x,y]}f(z)}.$$ Then $\dim(z) = f(z)$. (I didn't really check, but this should work..)