Does every embedding $\varphi:\mathrm{UT}(n,\mathbb{R})\to\mathrm{UT}(m,\mathbb{R})$ extend to $\bar{\varphi}:T^*(n,\mathbb{R})\to T^*(m,\mathbb{R})$?

Here $T^*$ means upper triangular with positive diagonal entries and $\mathrm{UT}$ means upper triangular matrices with all diagonal entries equal to 1. For what it's worth, the $\varphi=\varphi_n$ that I have in mind give rise to a free and transitive (aka simply transitive) action of the domain on $\mathbb{R}^{m-1}$ where $m=\frac{n(n-1)}{2}+1$.

Does every injective group homomorphism $\varphi:\mathrm{UT}(n,\mathbb{R})\to\mathrm{UT}(m,\mathbb{R})$ admit an extension $\bar{\varphi}:T^*(n,\mathbb{R})\to T^*(m,\mathbb{R})$?

An affirmative answer to this question implies an affirmative answer to this question.

(In the other direction, any $\bar{\varphi}:T^*(n,\mathbb{R})\to T^*(m,\mathbb{R})$ restricts to a homomorphism $\mathrm{UT}(n,\mathbb{R})\to\mathrm{UT}(m,\mathbb{R})$, since $\mathrm{UT}$ is the derived subgroup of $T^*$.)

-

This question has been asked and answered on MathOverflow. I have replicated the accepted answer by YCor below.

Here's a counterexample ($m=n=3$) which is a continuous homomorphism and actually probably also works for your second question with $\mathbf{Q}$.

In short: most automorphisms of $UT(3)$ do not extend to $T^*(3)$.

Since I deal with continuous automorphisms, it boils down to a Lie algebra problem. An automorphism of $UT(3)$ induces an automorphism of its abelianized subgroup, giving a $2\times 2$ matrix and every invertible matrix occurs this way. But my claim is that if the automorphism extends to $T^*(3)$ then (some power of) this matrix has to be diagonal.

Sketch of argument: I work upside down by considering an automorphism of $T^1(3)$, the group of determinant 1 matrices in $T^*(3)$ (it's enough and more convenient to deal with it) and describe its restriction to $UT(3)$.

First, because $UT(3)$ is the derived subgroup, it is stable. Write $T^1(3)=D.UT(3)$ where $D$ is the group of diagonal matrices. Since $D$ is a Cartan subgroup in $T^1(3)$ (that is, its Lie algebra is nilpotent and self-normalized, see Bourbaki, Groups and Lie algebras) and is unique up to conjugacy, it is mapped to a conjugate subgroup. So after composing by a conjugation, we can suppose $D$ mapped into itself. Now any automorphism of $T^1(3)$ induces a finite order automorphism of $D$: indeed, any one-parameter group of automorphisms of $T^1(3)$ induces the identity on $D$, as we see using the fact that the derived subgroup of the semidirect product $\mathbf{R}\ltimes T^1(3)$ is nilpotent (hence contained in the nilpotent radical $UT(3)$ of $T^1(3)$). So after conjugation, some power of the automorphism acts on $D$ as the identity and therefore preserves the weight decomposition of the Lie algebra of $UT(3)$ induced by the action of $D$, and thus induces a diagonal automorphism of the derived subgroup of $UT(3)$.

If you don't follow the argument you can also compute the group of continuous automorphisms of $T^*(3)$ and check that no one maps a matrix $\pmatrix{1 & x & * \cr 0 & 1 & y \cr 0 & 0 & 1\cr}$ to a matrix of the form $\pmatrix{1 & x+y & * \cr 0 & 1 & y \cr 0 & 0 & 1\cr}$.

NB: it's unclear from your question if you mean "extends as an automorphism" or "extends as an endomorphism". However, it is not hard to show that an endomorphism of $T^1(3)$ that is injective on $UT(3)$ remains injective on $T^1(3)$, and it easily follows that an automorphism of $UT(3)$ extends as an endomorphism of $T^*(3)$ iff it extends as an automorphism.

-