This is correct behaviour -- you cannot provide third-party libraries that run in the CMS context. DXM is a SaaS product so all CMS template code runs remotely in the service infrastructure. There are significant security and quality of service risks in allowing developers to upload and run any code they wanted inside the service.
However, if we look at the specifics of AWS S3, you will notice that you cannot create "folders" in S3 per se -- you can use a convention that assets with a shared prefix can be used to group files and give the effect of folders.
In your case, you don't need to create the folders programmatically. If you have publishing packages in the CMS set up to publish to AWS S3, the folder structure in the CMS will be part of the filename and S3 will interpret the "path" elements of the filename as if they were folders. Note: you can control the filenames for assets directly through the filename.aspx and assetfilename.aspx handlers.
For example, if you have a folder structure in the CMS like this:
/site-root
/en
/articles
Article One
The resulting filename will be something like:
/en/articles/article-one
and that will be the filename the asset is published to S3 with.