No. That arrangement would not work.
All the Juicebox gallery files must be on the same domain/subdomain as the page containing the JavaScript embedding code.
Please see this web page for more information about the JavaScript same-origin policy.
If your JavaScript embedding code is on a page on www.mydomain.com, then the gallery files would also need to be on that domain.
Otherwise, you could embed your gallery using an <iframe> (documented as Option #2 here).
You could upload your gallery folder to www.gallery.mydomain.com (and the gallery would be actually be embedded in the 'index.html' file within the gallery folder on that domain) and you could then load the gallery's 'index.html' file into an <iframe> on a page on www.mydomain.com.
However, please note that when embedding a gallery in an iframe, the 'Expand Gallery' button is disabled and the 'Back Button' will not work.