Create an empty template using the following guide. In order to do that, simply click Next when Template Creation Wizard asks to install the application into the temporary container.
When the template is created and installed, create
C:\vz\Templates\TemplateName\with the following content:
set VPSID=%~3 vzctl exec --skiplock %VPSID% ServerManagerCmd -install Name_of_the_Role -restart
Replace Name_of_the_Role with the name of a role or a feature to be installed. For example, NET Framework 3.5 on Windows 2008 R2 can be installed by replacing the name with