Can I start writing my PhD thesis from the second year?
It is probably a good idea to keep a running outline of your work as you go. Also, sometimes you get stuck for some period of time - say waiting for experiments to mature. In those periods if you can't otherwise make progress it might be a good idea to write up (and to revise) what you already know. 

I wouldn't do this to "shorten" the time, however, but rather to keep myself on track and to keep an overview of the work in mind. 

One advantage of this, if you have the discipline to do it, is that the thesis gets revised many times this way before you finish, rather than only once or twice. 

In short, it could be time wasted or time well spent, depending on when you do it and how you approach it.