Inspired by the brilliant answer by Martin R: https://math.stackexchange.com/a/4679552/820472 to the question Does there exist $M>0$ such that every $x,y\in U$ can be connected by a path $l$ with $|l|< M|x-y|$ in an open, bounded and path-connect set $U$?, I got even more curious about the possibility of the constant $M$. But first a recap:
In the solved case I asked whether for $U\subset\mathbb{R}^n$ that is open, bounded and connected the following would hold: can you find an $M>0$ such that every $x,y\in U$ can be connected to each other by such a polygonal chain that the length of $l$ satisfies $|l| < M|x - y|$? Note that any two points of an open and connect set $U$ can be connected to each other by a polygonal line.
(New version:) Let $U\subset\mathbb{R}^n$ be as before, but assume that $K\subset U$ for some non-empty compact and connected subset $K$. Let us now ask the question in terms of $K$: Can we find such an $M$ that if we connect any two points $x, y\in K$ by a polygonal line $l$ contained in $U$, that now $|l| < M|x - y|$ for some $M$ independent of $x, y$? Morally we would now be approximating the prior situation by forgetting some, possibly small, amount of $U$ which lies outside of $K$.
I have one sketch idea how one could start working on the problem, but I am not sure how to conclude that the to be seen $M$ is finite: Since any two points inside $U$ can be connected by a polygonal line, the function
$$f(x,y) = \inf\{\text{length($l$)}: l\in \text{all polygonal paths from $x$ to $y$ in $U$}\}$$
is well-defined. For us $f$ is sort of a discretized geodesic on $U$.Therefore if $M = \sup\{f(x,y)|x - y|^{-1}: x,y\in K\}$ is finite, it most certainly fits the bill. But then with what tools can we guarantee $M$ to be finite?
This is actually true. The key is noticing that the quantity $f(x, y)/|x - y|$ does not blow up as $x, y \in K$ get closer and closer together, which was the problem in the previous example. So let us prove this key fact:
Suppose $(x_i, y_i)_{i \in \mathbb{N}}$ be a sequence, $x_i \neq y_i$ in $K \times K$ such that $|x_i - y_i| \to 0$. As $K \subset U \subset \mathbb{R}^n$ is compact, so must be $K \times K$. Thus there is a point $u \in K$ such that $x_i \to u$ and $y_i \to u$. Now since $U$ is open and $u \in U$, there is an open ball $u \in B \subset U$. So there must be an $I \in \mathbb{N}$ such that $x_i, y_i \in B$ for all $i \geq I$. But open balls are convex; so the straight line $l_i$ from $x_i$ to $y_i$ is entirely contained in $B$ and therefore $U$. So $f(x_i, y_i) = \text{length}(l_i) = |x_i - y_i|$ and $f(x_i, y_i)/|x_i - y_i| = 1$ for all $i \geq I$.
In fact you can generalize the above technique to show that your original $f : K \times K \to \mathbb{R}$ is continuous (this time start by fixing $x, y \in K$ that is polygon-path-connectable in $U$ and a sequence $(x_i, y_i) \in K \times K$ s.t. $(x_i, y_i) \to (x, y)$; show $f(x_i, y_i) \to f(x, y)$ by using convexities of appropriate open balls around $x$ and $y$ that are contained in $U$).
Now define the function $g : K \times K \to \mathbb{R}$: $g(x, y) = f(x, y)/|x - y|, x \neq y$ and $g(u, u) = 1$. Even though it is defined by cases, by our result above (and the continuity of $f$) $g$ is actually continuous. So since $K \times K$ is compact $M = \sup_{K \times K} g(x, y)$ is finite and attained by $g$ on $K \times K$.