Can you try with this?
$ipGateway='192.168.0.1'
$ipDevice='vmk2'
$esx=Get-VMHost-Name $VMHost
$netSys=Get-View-Id $esx.ExtensionData.ConfigManager.NetworkSystem
$stack=$esx.ExtensionData.Config.Network.NetStackInstance|where{$_.Key-eq'vmotion'}
$config=New-Object VMware.Vim.HostNetworkConfig
$spec=New-Object VMware.Vim.HostNetworkConfigNetStackSpec
$spec.Operation=[VMware.Vim.ConfigSpecOperation]::edit
$spec.NetStackInstance=$stack
$spec.NetStackInstance.ipRouteConfig.defaultGateway=$ipGateway
$spec.NetStackInstance.ipRouteConfig.gatewayDevice=$ipDevice
$config.NetStackSpec+=$spec
$netsys.UpdateNetworkConfig($config,[VMware.Vim.HostConfigChangeMode]::modify)
And if it still shows errors, have a look at the vpxd log.
There might be more clues in there.