As luck would have it, the total at the register came to 777 yen.

Literal

Coincidentally, register [at-での] total-amount [topic-は] 777 yen [copula-であった].

くしくも is a literary adverb meaning 'as fate would have it / by a strange coincidence.' 777 is a lucky number (like 777 on a slot machine). であった is the formal/literary past copula, characteristic of written narrative. A compact observational sentence with a numerological punch.