To use the Set-VMHostSnmp cmdlet you have to be connected to the ESXi host directly. The following example will connect to an ESXi host named ESX01 and sets SNMP to enabled and a read-only community example-community (Example 1 from the Set-VMHostSnmp help):
Connect-VIServer ESX01
$vmhostSNMP = Get-VMHostSNMP
Set-VMHostSNMP $vmhostSNMP -Enabled:$true -ReadOnlyCommunity 'example-community'