ffmpeg - Zoompan IN and Out alternately
You need to use state e.g.

ffmpeg -i src.png
 -vf zoompan=d=300:z='if(gte(zoom,2)+eq(ld(1),1)*gt(zoom,1),zoom-0.04*st(1,1),zoom+0.04+0*st(1,0))'
o.mp4


This expression zooms from zoom=1 to zoom=2 in steps of 0.04. Remember, zoom is initialized to 1. The above will create 6 loops.

In st(store) and ld(load) functions, the first argument is variable id (0 to 9), and the second is the value.