Here is how to do it:
1. Open module settings (F4), or right click on a module and select open module settings
2. Navigate to the artifacts tab on the left
3. Click the green + symbol and select JAR -> Empty
4. Move the compiled output of the module you want to put into the .jar from the available elements (on the right) into the .jar (on the left) by double clicking on it
5. Set the name of your .jar, and change the output directory to the scripts folder:
6. Select apply.
7. To then build your script, in the navbar select Build -> Build Artifacts... -> Select the artifact you want to build