Hi,
Well, it's not as easy as I though, It would first require to change the $select variable to calculate whether the product has stock or not as a new column so that you could apply the sorting on it. Otherwise, if you apply the sorting directly on the product_quantity column, it will just order the products based on the stock and that's not what you want.
So it's possible with a plugin, but it will require a bit more work. I would recommend to hire a developer to work on that.
Basically, as a developer, you want to var_dump the content of the different variables of that function, and get the whole MySQL query from the debug data at the bottom of the page when you activate the debug setting of the Joomla config.
Then, you want to change the $order variable like that:
$order = 'alias_column ASC, '.$order;
and you want to change the $select variable to calculate the "alias_column to be 0 or 1 based on the product_quantity column with a "case":
dev.mysql.com/doc/refman/5.7/en/case.html