How much does this Integer score?
Mathematica, 63 bytes

s+Max@If[PrimeQ[s=Tr[d^Range@Length[d=IntegerDigits@#]]],d,-d]&amp;


Pure function taking a positive integer as input and returning an integer. Directly performs the indicated computation, with all the long Mathematica command names that requires. Perhaps the one innovation is noticing that, if d is the list of digits of the input, then the last addition/subtraction is the same as adding Max[d] if the initial sum was prime, and adding Max[-d] if not.