How to write a wave function for infinite potential well with different width than from 0 to a?
Well, yes; the original length $a$ is just a symbol and you can replace it with whatever other quantity you wish. The relevant wavefunctions are thus just

$$\psi_n = \sqrt{\frac{1}{a}}\sin\left(\frac{n\pi x}{2a}\right)$$

You can verify that these wavefunctions are still normalised correctly by explicit integration.