Interesting idea.
At the time of writing I don’t know how feasible it is, but I have done a little digging into the Plugin API and some things seem possible. The DatabaseManager interface provides methods such as generateCreateSQL() which might make this possible.
However… I don’t see anything that is specifically related to exporting SQL code into a sql datafile and at this time I’m not sure if these methods do the same as (for example) the ‘create database’ and ‘generate SQL’ options which can be found in the Tools -> DB menu and a diagram context menu respectively.
One way to find out though; I added the idea to my Win10 todo list and I’ll probably look into it a bit further tomorrow evening