I am creating WMTS server side. The problem is that I cannot find any solution where I will be able to generate GetCapabilities xml response in java using some libraries like geotools or similar. Can somebody help me with this?
Your best bet is to study the geowebcache sources to see how they do it. But is a pretty simple schema to follow assuming you have implemented the spec correctly.