After installing software, I need to allow it to load in Security & Privacy. How do I do it with a script?
That's the whole point of Gatekeeper.  The user needs to manually allow for an application to run or have access to control your computer.  Otherwise any malicious application could just grant itself access and permissions to run and control your computer. 

Your best option would be creating a Readme.txt file with explicit step-by-step instructions on how to grant access and permissions for that application, to control your computer, in System Preferences.app

This following AppleScript code, In MacOS Mojave, will bring you to the System Preferences window where you can address the "If I click the Allow button to the right" issue that you have mentioned.

tell application "System Preferences"
    activate
    tell its pane id "com.apple.preference.security"
        reveal anchor "General"
    end tell
end tell


And this AppleScript code will bring you to where you need to set Accessibility, Full Disk Access, and Automation privileges for the application.

tell application "System Preferences"
    activate
    tell its pane id "com.apple.preference.security"
        reveal anchor "Privacy_Accessibility"
    end tell
end tell