When generating HDL and realizing hardware in general, control flow like break is not feasible. The full data path must be set in the hardware to always look at every possible bit. That's why the for-loop must run for a constant number of iterations. There's no concept of a program counter and early bail in a calculation. Using a for-loop and if-else is the best way to do this type of calculation. A computation like 'any' is a very simple calculation in hardware because it is just a bunch of OR operations. If you are looking for an index of a value, there will be a lot more hardware required like muxing in a priority structure where the MSB is considered first.
Here is how I would write the code in an extremely compact way.
function y = fcn(u)
% return 0 if no 1's, else return one-based idx of first found 1
% return value is smallest possible fixpt value for idx
y = fi(0, 0, ceil(log2(numel(u))), 0);
for ii = cast(1:numel(u), 'like', y)
if y == 0 && u(ii) == true
y = ii;
end
end
end