Imagine I have a 2/2 creature that can be megamorphed, can I block with it and pay its megamorph cost before damages are done?
Yes you can. Morph/megamorph can be used any time you have priority. After declaring blockers but before combat damage is assigned and dealt, there will be a priority pass where you can megamorph your creature.
702.36e: Any time you have priority, you may turn a face-down permanent you control with a morph ability face up. This is a special action; it doesn't use the stack...