You can certainly do that:
testRunner.testCase.testSuite.project.getTestSuiteByName('MyTestSuite').getTestCaseByName('MyTestCase').setSetupScript('log.info "setup"')
testRunner.testCase.testSuite.project.getTestSuiteByName('MyTestSuite').getTestCaseByName('MyTestCase').setTearDownScript('log.info "teardown"')
If you are using the pro version, you can also configure the TestRun beforeRun and afterRun events to execute a script, which avoids having to copy anything to your test cases.
If you are using the free version, here is another suggestion. Store your setup and teardown scripts in files, then in the project Load script put code like this:
def su = new File("setup.txt").text
def td = new File("teardown.txt").text
project.getTestSuiteList().each { testSuite ->
testSuite.getTestCaseList().each { testCase ->
testCase.setSetupScript(su)
testCase.setTearDownScript(td)
}
}
This will cause every test case's setup and teardown scripts to be replaced when the project is first loaded.