I’ve used that technique before, yes.
May also be easy to do something like
wait /bin/sh -c 'echo newentry >> /etc/hosts'
Or
action uses wow64 redirection {not x64 of operating system}
wait CMD.exe /c echo newentry >> {pathname of file "drivers\etc\hosts" of native system folder}
(Wrapped in a condition for each OS type)
Edit: also assuming there’s no incorrect “old” version of the entry