Use some component state. The input is a controlled input with value set from state and updates state on onChange, and the button updates state on onClick.
I don't quite understand the latter half of your question though. The input doesn't need to know/understand what a button is or if it was clicked, and the button doesn't need to know it's updating a value of an input. They are completely independent of each other and the state of the component is the only thing that "links" them.
export default function App() {
const [value, setValue] = useState('');
return (
<div className="App">
<input type='text' value={value} onChange={e => setValue(e.target.value)} />
<button type="button" onClick={() => setValue('Click Me')}>Click Me</button>
</div>
);
}
