There is also a command line tool called hdtsparql in the hdt-java
distribution that allows exactly this. It used to support only SELECT queries, but I've enhanced it to support CONSTRUCT, DESCRIBE and ASK queries too. There are some limitations, for example only CSV output is supported for SELECT and N-Triples for CONSTRUCT and DESCRIBE.
Thank you for sharing.
The tool is in the hdt-jena package (not hdt-java-cli where the other
command line tools reside), since it uses parts of Jena (e.g. ARQ).
There is a wrapper script called hdtsparql.sh for executing it with the
proper Java environment.
Does this tool work nicely with large HDT files such as wikidata? Or does it need to load the whole graph+index into memory?