Yes, this is what "recipes" are for (link at the very top of the forge panel). You can create a recipe, which is just a bash script, and have that run when creating the server. When you create the server, there is a "post-provision recipe" dropdown in the server settings section (like when you choose the type of server, php version, etc.), so you can just select the recipe you made there. So it will run that code after the server is created.
There's actually a forge recipe site that you can check to see if they already have what you're needing, or see how they create theirs as an example, etc. http://forgerecipes.com/