In short: Order Sharing Settings have to be set via the UI.
Solution: try to build selenium automation for this, maybe have a start here.
So what makes me say this?
First of all let's have a look at the example scratch org setup I made:
Like told from Novarg before, you can change the sharing of a global class.
I have already modified the sharing of global classes previously and I have not encountered any problems.
Remember that for the security review, you have to explain the reasons why a class is branded "without sharing".
According to the documentation, you can edit API version and the code of the class, but not the name. Given that with sharing and without sharing is not a part of a name, I would say that you can change it.
Probably a bit late but better than never.
You can use sfdx force:mdapi:deploy -d data/standard-object-stub/ -w 1 -u $SCRATCH_ORG_ALIAS with a package.xml that references a Case.object file with the following content in a objects subfolder before you deploy your sources
<?xml version="1.0" encoding="UTF-8"?>
The community user should have access to Loan_Doc_Sort__c record to upload files on it.
You have few options,
Change the OWD of Loan_Doc_Sort__c to public read-only external
Create a manual share record for Loan_Doc_Sort__c after insert and
share it with the commnunity user.
Ensure The community user is the one creating the Loan_Doc_Sort__c in the test ...