It's definitely possible to define such a function through the C API as can be witnessed by looking at json_build_array() for example:
Unfortunately trying to create a SQL or pl/pgSQL function like this fails
CREATE OR REPLACE FUNCTION my_function( VARIADIC _args anyelement[]) RETURNS ...
and this is no surprise as the PostgreSQL documentation mentions that 'VARIADIC' only works for arrays (and it seems there is no such thing as an anyelement[]). Does anybody know how to get this working without having to write a C function ?

polymorphic. That will also lead you to Polymorphic Types.