In PHP you need to use double quotes for a string if you want to pass a variables into it.
Additionally if you want to pass user input as a shell script argument, you need to sanitize it, otherwise user will be able to execute any shell script on your machine. In PHP you can use escapeshellarg for this.
Finally, your code should look like this:
$HOSTNAME=escapeshellarg("s/nome/$SEU_HOSTNAME/"); shell_exec (" cd /etc/ sudo sed -i $HOSTNAME hosts sudo sed -i $HOSTNAME hostname ");