Let $X,Y$ be topological spaces, let $f$ be a continuous map from $X$ to $Y$ and let $g$ be a continuous map from $Y$ to $X$. Write $C_f$ for the mapping cone of $f$; i.e., $\{*\} + X\times I + Y$, where we identify $*$ with $(x,0)$ and identify $(x,1)$ with $f(x)$.

There is a map $h\colon C_f\to C_f$ defined as follows. \begin{align} h(*)&=*\\ h((x,s))&=(gf(x),s)\\ h(y)&=(g(y),1)=fg(y) \end{align}

Moreover, the map $h$ is nullhomotopic. Consider the following homotopy, for example. \begin{align} H(*,t)&=*\\ H((x,s),t)&=(gf(x), \min\{s,t\})\\ H(y,t)&=(g(y),t) \end{align}

Alternatively, we could use $st$ rather than $\min\{s,t\}$.

The map $h$ can be constructed using the universal property of the mapping cone, which lets us construct a pointed map $(C_f,*)\to (Z,*)$ from a map $k\colon Y\to Z$ and a homotopy from $k\circ f$ to $*$. In this case, the map $k$ is $$ Y \xrightarrow{g} X \xrightarrow{f} Y \hookrightarrow C_f\,, $$ and the homotopy in question is given by lifting the usual homotopy from the inclusion $Y\hookrightarrow C_f$ to $*$ along the map $fg$.

What properties do we need to construct the homotopy $H$. As far as I can see, the existence of the map $(s,t)\mapsto\min\{s,t\}$ doesn't come into play in the proof of the universal property of the mapping cone, so it can't follow straight from the universal property. On the other hand, this map is part of some axiomatic presentations of homotopy theory (e.g., Cubical Type Theory), so it should be easy to define it in that setting. What structure from the homotopy $2$-category do we need in order to construct the homotopy $H$?