That's not a function, it's a defined type. You declare instances just as you would declare instances of a built-in type, such as Package itself. You cannot call it as if it were a function. You really ought to put it into a module, though.
With that said, what you propose to do is one of the persistent bad ideas in the Puppet universe. Using such a definition to allow multiple points of declaration of a given resource (only one of which will be effective) makes your manifest set harder to maintain and opens it to subtle bugs because you must keep all declarations of the target resource synchronized. If you don't, then your manifest set thereby has an internal inconsistency that you prevent Puppet from diagnosing. All manner of strangeness may then ensue. Moreover, the approach is only effective for a given resource if you apply it to every declaration of that resource.
The best way to avoid multiple-declaration errors is to factor out multiple declarations of any given resource into a single class that the other erstwhile declaration points will rely on. That is usually fairly natural. It may involve modifying third-party modules, but so does any approach based on the defined() function or similar.
John