jBPM nodes can define dataoutput that then are used to set process variables, for instance human task can have defined dataoutput and its assignments to achieve what you described. Don't think script task supports that and looking at your case not sure you should use it to set variable like this. Variables are set/changed based on some steps in the process or external interaction. So better is to look at what can change a variable and define it via dataoutputs.
HTH