This construct does not seem to be supported in PL / SQL yet. Presumably, it will be added in a future version.
In the meantime, this is unpleasant, but you can use dynamic SQL, which continues to run your working statement in the context of SQL, where this is understood:
DECLARE
c number;
BEGIN
EXECUTE IMMEDIATE '
WITH
FUNCTION calculate(i IN NUMBER) RETURN NUMBER
AS
r number;
BEGIN
r := i*i;
RETURN r;
END;
select calculate(2) from dual'
INTO c;
DBMS_OUTPUT.PUT_LINE(c);
END;
/
4
select into , with PL/SQL , . PL/SQL. Oracle Live SQL, 12.2.0.1, 12cR2.