Give an example or prove it's impossible.

Give an example of a continuous function which is defined on $(0,1]$ with range $(0,1)$.

I think it might be possible if there is a function defined on $(0,1]$ and oscillating between $(0,1)$, but how to write the function explicitly?

You can use $f(x)=\frac{(1-x)\sin(1/x)+1}{2}$.
You know that $|\sin(y)|\leq 1$, so, when we multiply it by $(1-x)$, for $x\in(0,1]$ we get a smaller number in absolute value. Therefore $|(1-x)\sin(1/x)|<1$. This implies that $0<((1-x)\sin(1/x)+1)/2<1$.
Now, in $(0,1)$ there are infinitely many points arbitrarily close to $0$ for which $\sin(1/x)=1$ and for likewise for which $\sin(1/x)=-1$.
Therefore, following a such a sequence of points we get either $((1-x)\sin(1/x)+1)/2\to (1\cdot 1+1)/2=1$, following a sequence of points in which $\sin(1/x)=1$ or $(1\cdot (-1)+1)/2=0$, following a sequence of points in which $\sin(1/x)=-1$. Therefore, the function attains values arbitrarily close to $0$ and to $1$. Since the function is continuous in $(0,1]$ all values in $(0,1)$ are attained.
The class of continuous functions is quite large. So, there is a lot of freedom to choose examples from. The whole idea above was to pick a function such that $f(1)$ is inside $(0,1)$, say $1/2$. And then such that towards $x=0$ it covers larger and larger portions of $(0,1)$.
You can achieve the same behavior by defining $f(1)=1/2$, $f(1/2n)=1-1/n$, $f(1/(2n+1))=1/n$, and joint these points with straight lines to fill up the graph of $f$.