Answer: \(y=\dfrac{1}{2}\left(\tan \dfrac{\theta}{2}+\cot \dfrac{\theta}{2}\right)\), so equivalently \(y=\csc \theta\).
Start with
\(\sin \theta\,\dfrac{dy}{d\theta}+y=\tan \dfrac{\theta}{2}.\)
Since \(0\lt \theta\lt \pi\), we have \(\sin\theta\neq 0\), so divide through by \(\sin\theta\):
\(\dfrac{dy}{d\theta}+\csc\theta\,y=\dfrac{\tan(\theta/2)}{\sin\theta}.\)
This is a linear differential equation. Its integrating factor is
\(\mathrm{IF}=e^{\int \csc\theta\,d\theta}=e^{\ln \tan(\theta/2)}=\tan \dfrac{\theta}{2}.\)
Multiplying the equation by \(\tan \dfrac{\theta}{2}\):
\(\dfrac{d}{d\theta}\left(y\tan \dfrac{\theta}{2}\right)=\dfrac{\tan^2(\theta/2)}{\sin\theta}.\)
Using \(\sin\theta=2\sin(\theta/2)\cos(\theta/2)\),
\(\dfrac{\tan^2(\theta/2)}{\sin\theta}=\dfrac{1}{2}\tan \dfrac{\theta}{2}\sec^2 \dfrac{\theta}{2}.\)
So
\(y\tan \dfrac{\theta}{2}=\int \dfrac{1}{2}\tan \dfrac{\theta}{2}\sec^2 \dfrac{\theta}{2}\,d\theta + C=\dfrac{1}{2}\tan^2 \dfrac{\theta}{2}+C.\)
Hence
\(y=\dfrac{1}{2}\tan \dfrac{\theta}{2}+C\cot \dfrac{\theta}{2}.\)
Use \(y=1\) when \(\theta=\dfrac{\pi}{2}\):
\(1=\dfrac{1}{2}+C\), so \(C=\dfrac{1}{2}.\)
Therefore
\(y=\dfrac{1}{2}\left(\tan \dfrac{\theta}{2}+\cot \dfrac{\theta}{2}\right).\)
Since
\(\dfrac{1}{2}\left(\tan \dfrac{\theta}{2}+\cot \dfrac{\theta}{2}\right)=\dfrac{1}{\sin\theta},\)
the solution may be written as
\(y=\csc\theta.\)