Complementing Mark's response:
For you to assign the value, you will use:
document.getElementById("idUnico").value = '<script>alert()</script>'
Now to read the value, you will use:
document.getElementById("idUnico").value
If it's a function within value, I believe you'll need to get it and inject it into HTML to make it available.
If your purpose is to do XSS, be more specific so that we can respond more effectively.
I believe this is not a good practice and can make it difficult to maintain your application.
I hope I have helped, but I believe there may be a more cohesive way to solve your problem, maybe explaining the context helps us help you.
EDIT1: The contents of the variable is a string, if you have problems with using just pass only the function or escape the characters. Notice that value stores a string, not the JS function. An example of this is that you could very well convert your function to base64 and save to variable. Next, get the string and make the decode to get the function clean.