Ahh I think I see where the confusion lies:

In this UDF example, and the one Doc is referring to, the UDF returns a specific value - valid data.

This is not correct. Well, not what you mean anyway

The value of SetProductKey is not a datum as such - it is the same error code that @ERROR is set to:

SetProductKey Method of the Win32_WindowsProductActivation Class
The SetProductKey WMI class method updates the system product key for a computer.

This topic uses Managed Object Format (MOF) syntax. For information on using this method see Calling a Method.

uint32 SetProductKey(
string ProductKey

[in] Unique product key that is licensed for use on the computer. Product keys are alphanumeric strings of 25 characters formatted as follows: xxxxx-xxxxx-xxxxx-xxxxx-xxxxx. The product key must be valid for the media type. Media types include retail, volume-licensing, and OEM.
Return Values
If the method succeeds and the product key is valid, the method returns 0 (zero) and the corresponding product key is updated. Otherwise, the method returns one of the WMI error constants.