Intermediate value theorem for $\sin x.$ How is intermediate value theorem valid for $\sin x$ in  $[0,\pi]$?

It has max value $1$ in the interval $[0,\pi]$ which doesn't lie between values given by $\sin0$ and $\sin\pi$.
Let $f\colon[a,b]\longrightarrow\mathbb R$ be a continuous function and let $y\in\mathbb R$. The intermediate value theorem  says that if $f(a)\geqslant y\geqslant f(b)$ or if $f(a)\leqslant y\leqslant f(b)$, then there is a $c\in[a,b]$ such that $f(c)=y$. But it says nothing if $y$ lies outside the interval bounded by $f(a)$ and $f(b)$. So, there is no contradiction here.
In general, any time you have a theorem, "If ____, then ____," it really means, "If ____, then ____ and maybe some other stuff not mentioned here also happens."
Because when you're working in just about any branch of mathematics,
no matter how thoroughly you describe the implications of any mathematical fact there is always some other possible case you could have said something about but didn't.

The only things you can rule out are the things the theorem explicitly says cannot happen.
Unless a theorem says "and there are no other values outside this interval,"
don't assume all the values are inside the interval.

In your example, the value $\sin(\pi/2)=1$ is part of the "other stuff"
that "also happens."