I was wondering if there is a way to link a document library folder (within a main site) to the document library of a sub site in SharePoint Online (Office 365)?
If you mean that your main site’s document library should display all your sub site library’s documents, you can do that as a redirection.
But you can run a workflow to copy documents to main site library whenever it is added to sub site.