It took some time, but I think I've finally narrowed down the rules that determine how long the ledge will be unavailable if you get hit. It's not as simple as you'd think.
Rule 1. You will be allowed to grab the ledge on the 54th frame following hitlag (unless Rule 2 applies and Rule 3 or 4 does not apply).
Rule 2. If you are hit hard enough that you will be forced to enter the tumble state, you cannot grab the ledge until the frame that you would enter the tumble state (unless Rule 3 or 4 applies).
Rule 3. If while falling your character model is pushed/shifted slightly out off-stage by the edge of the stage itself, Rule 2 will not apply and you will be allowed to grab the ledge as soon as you are within range so long as Rule 1 allows it.
Rule 4. If you avoid the tumble state entirely by e.g. using a move that can grab the ledge (Cloud Up-B, airdodge then tether, etc), you can circumvent Rule 2 and grab the ledge so long as Rule 1 allows it.
That's a bit convoluted, but it's really quite simple, so I'll give some examples.
Let's say you're hit with an attack that has 10 frames of hitlag. Well Rule 1 says that you'll be able to grab the ledge on frame 64 at the earliest counting from the moment you were hit (because it's 10 + 54).
But let's say that your percent was high enough for the same move to give you enough knockback to induce a tumble state, and the tumble state would have only started on frame 72 at the earliest. Rule 2 then says that you'd be allowed to grab the ledge on frame 72 at the earliest instead.
Ok, but when you were hit with this same move at the same percent that would have made it so you'd enter the tumble state on frame 72, let's say that you were smart so you DI'd/drifted to position yourself such that as you were falling you were nudged/moved by the edge of the stage out off-stage, or you used a move such as Cloud's Up-B or a tether before the tumble state had kicked in. In that case, Rule 3 and 4 say that you'd be allowed to grab the ledge on frame 64 at the earliest again.
Edited to include Rule 4.