Your question is not very clear.
If "source type" is "Query", "Query one row", "Feed", or "Media Resource": You must supply a SELECT statement.
yes, you can use a function in a SELECT statement.
select f( :input ) as pseudo_col_name from dual;
Also, PIPELINE FUNCTION comes to mind.
If "source type" is "PL/SQL"
(as far as i know) The only way to return data from "an anonymous PL/SQL block" to the web browser is by using the sys.htp package.
If you have a large amount of data to return (eg > 32,767 bytes), you'll need to LOOP over the CLOB.
Since you want JSON format, you will need to use a package like dtr's package or build-your-own.
(I like this site: https://code.google.com/p/plsql-utils/ )