OP seems to be asking about the case that uses a smoothly varying isotropic refractive index $n({\bf r})$ with no jumps and with no reflections/mirrors.
Let us assume that OP's given curve $\gamma:[a,b]\to \mathbb{R}^3$ is smooth and has no self-intersections, i.e. it is a simple curve. Also let us assume that $\gamma$ has finite length.
Then we can sketch a construction as follows:
In a tubular neighborhood $\Omega\subseteq\mathbb{R}^3$ of the curve $\gamma$, we can pick a function $W:\Omega\to\mathbb{R}$, such that the gradient $\nabla W$ restricted to $\gamma$ is non-vanishing and parallel to $\gamma$.
(E.g. for each point $p$ along the curve $\gamma$, there is a unique hyperplane $\Pi_p$ perpendicular to $\gamma$. We could choose the function $W$ to have the hyperplanes as level sets.)
($W$ plays the role of the eikonal in geometric optics and is related to Hamilton's characteristic function in Hamilton-Jacobi theory, cf. Ref. 1.)
We next choose the refractive index $n:=|\nabla W|$.
The surfaces of constant $W$ becomes the surfaces of constant optical phase and thus define the wave fronts. The curve $\gamma$ becomes a geodesic/ray trajectory in this geometry.
(If the curve $\gamma$ is closed, then $W$ becomes multi-valued, but since we are just interested in the length of the gradient $|\nabla W|$, we just have to make sure that it doesn't depend on the branch of $W$.)
We could accentuate the construction by letting the refractive index profile $n$ become gradually smaller away from $\gamma$, but it is in principle not necessary. (This is the idea behind an optical fiber with a smooth gradual fusing of the cladding, cf. many of the other answers.)
Finally extend $n$ in a smooth way from the tubular neighborhood $\Omega$ to all of space $\mathbb{R}^3$.
References:
- H. Goldstein, Classical Mechanics, 2nd edition; Section 10.8.