As a simple example, suppose we have a function $f: \mathbb{R}^3 \to \mathbb{R}$ defined on the set (and taking $+\infty$ everywhere else),
$$\{x \in \mathbb{R}^3| x_1 \in [-1, 1], x_2 \in [-1, 1], x_3 = 0\}$$
The set has no interior but a relative interior given by $(-1,1) \times (-1,1) \times \{0\}$.
Similarly, consider sets such as $\{x \in \mathbb{R}^3| \langle e, x\rangle = 1, x_i \geq 0\}$, where $e$ is the one-vector. Once again, it has no interior, but has a relative interior relative to the hyperplane $\langle e, x \rangle = 1$ given by $\{x \in \mathbb{R}^3| \langle e, x\rangle = 1, x_i > 0\}$,
Example functions could include:
$f(x) = \langle x, x \rangle$ for the first set
$f(x) = -\langle e, \ln(x) \rangle$ for the latter set
Are such function differentiable on such sets (i.e. the gradient exists)? If not, why? Can't seem to find any resource on this.
Edited per comment: Also, is it problematic if I were to pretend that the function was defined on the whole space, take the gradient there, and restrict it to the relative interior? For example, consider $f(x) = \langle x, x \rangle$ defined on the set $[-1, 1]^2 \times \{0\}$. What is wrong if I were to take the gradient as usual, $\nabla f(x) = 2 x$ and define it on the relative interior of the same set $(-1, 1)^2 \times \{0\}$?