The following should work in Pro, not sure about ArcMap since it uses Python 2.x.
Code Block:
from collections import defaultdict
def counter_gen():
counter = defaultdict(int)
v = None
while True:
counter[v] += 1
v = yield counter[v] if v else None
g = counter_gen()
next(g)
and Expression:
g.send(!ID!)
The code above works whether the table is sorted by ID groups or not. If the table is sorted by some other column, the code just takes the first ID value x and makes it 1, the second ID value x as 2, etc.... as it finds them.