Yes, you can unroot. You can also flash a stock ROM.
To root you have to unlock the bootloader. If you do this via the SONY website, there will be a record that you have unlocked. I would suggest you use Flashtool to unlock and then relock, if and when you want to.
I was wondering whether it is possible to un-root the Xperia Z2?
i.e. warranty issue bla bla bla ...
For instance I have rooted my Z2 - running a custom rom ... then what I would like to do is go back to stock rom and unroot the Z2?
To root you first need (at this point in time) to unlock the bootloader. To unlock the bootloader, you request a code from Sony. When you unlock the bootloader, it will show up in service menu and you can't undo it. From that point you can root/unroot as you please, but the bootloader remains unlocked and it will be like that nomatter what you do. So, if anybody from Sony Service checks your bootloader and you unlocked it, you might loose your warranty (as per Sony website). It doesn't matter you unrooted your device.
XDA Developers was founded by developers, for developers. It is now a valuable resource for people who want to make the most of their mobile devices, from customizing the look and feel to adding new functionality. Are you a developer?