If you have DB2 for LUW (and not DB2 for Z/OS which your link refers to), then you should follow correct documentation.
Refer to the CREATE FUNCTION (SQL scalar, table, or row) statement link with the following note about the MODIFIES SQL DATA clause:
Valid only for compiled scalar function definition and an inlined table function definition. A compiled scalar function defined as MODIFIES SQL DATA can only be used as the only element on the right side of an assignment statement that is within a compound SQL (compiled) statement.
This means, that it can't be used in the UPDATE statement, for example. Only in the SET statement of a compiled (BEGIN ... END, not BEGIN ATOMIC ... END) compound statement.
CREATE OR REPLACE FUNCTION TEST_MOD() RETURNS INT MODIFIES SQL DATA BEGIN RETURN 1; END DB20000I The SQL command completed successfully. CREATE TABLE IF NOT EXISTS TEST_MOD(I INT) DB20000I The SQL command completed successfully. BEGIN DECLARE V_RES INT; SET V_RES = TEST_MOD(); END DB20000I The SQL command completed successfully. BEGIN UPDATE TEST_MOD SET I = TEST_MOD(); END DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned: SQL0740N Routine "DB2ADMIN.TEST_MOD" (specific name "SQL250127142445606") is defined with the MODIFIES SQL DATA option, which is not valid in the context where the routine is invoked. LINE NUMBER=2. SQLSTATE=51034 BEGIN ATOMIC DECLARE V_RES INT; SET V_RES = TEST_MOD(); END DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned: SQL0740N Routine "DB2ADMIN.TEST_MOD" (specific name "SQL250127142445606") is defined with the MODIFIES SQL DATA option, which is not valid in the context where the routine is invoked. LINE NUMBER=3. SQLSTATE=51034