<p>I'd like to create a script to manipulate Apache2 configuration directly, reading and writing its properties (like adding a new VirtualHost, changing settings of one that already exists).</p>

<p>Are there any libs out there, for Perl, Python or Java that automates that task?</p>

This is the ultimate Apache configurator:
http://perl.apache.org/
exposes many if not all Apache internals to programs written in Perl.
For instance:
http://perl.apache.org/docs/2.0/api/Apache2/Directive.html
(Of course that it can do much much more than just configuring it).
On the other hand, it needs to be loaded and runs within Apache, it's not a config file parser/editor.