Yeah you can do that. You'd need to use a variable to keep track of the state of the latch. I'll attach a program that does this for CC7. You need two mappings. One from CC7 to a variable (I'll call it latch). The equation for this looks like:
if(input, !latch, ignore)
Which basically says "if the incoming CC value is not 0 then toggle the latch variable. Otherwise ignore the CC message."
Then you would have another mapping from the latch variable to CC7 so that every time latch changes it outputs a CC message.
Let me know if that works