How to implement this scenario for a stable opamp integrator?
Make a comparator instead of the voltage buffer. The R2 is optional but makes the output slightly hysteretic around 0.5 V input. Be sure to select an opamp/comparator part which has a common mode input range down to within 0.5 V of the negative supply and ideally ral-to-rail output, to provide a full swing digital signal.