Use encode and no ! for you input (! is there to mark start and end) and don't set text.
here_document_input ="""input 1 input 2 input 3 """ result = subprocess.run("program", input=here_document_input.encode(), shell=True)