Cycle or something similar in PL/SQL
set serveroutput on size unlimited
for i in (select 'alter user '||username||' account unlock' cmd
            from dba_users
           where account_status = 'LOCKED'
          )
loop
   dbms_output.put_line (i.cmd);
 --  execute immediate i.cmd;
end loop;
end;
/


This works. Be careful, I have seen ppl doing similar things without testing, effectively destroying databases, especially when using patterns and manipulating database objects with the results. If the output is OK, activate the execute immediate.