I put together a plugin that tackles the UI portion of this FR. It will add a controls to all inline queries (in live preview and reading modes) that let you collapse, sort, enable context, copy, hide the title, and hide the results.
I have not tried tackling the scripting aspect of this yet but there are plugin settings which allow you to change the defaults for all of the actions listed above.
The plugin can be installed using the BRAT community plugin and adding the beta plugin repository “nothingislost/obsidian-embedded-query-control”.
Issues and suggestions can be raised on the Github repo located here: https://github.com/nothingislost/obsidian-embedded-query-control
Here’s a quick video showing off what it can do: