Before the beginning of earth? Sure, why not.
Which means before the beginning of everything. It says "the heavens and the earth", which when those parts of the bible were written people thought of as the whole world.
There had not been an understanding of the universe we live in or the existence of other planets, solar systems let alone galaxies, people back then figured there just was the earth of indefinite two-dimensional extent, the heavens above and whatever underworld below. Which apparently doesn't differ too much from what somehow flat-earthers still believe today. 🤷♂️
And if you are the beginning and the end, you are finite. God never claims to be perpetual.
I'd argue that
being the beginning AND the end (of everything) in itself pretty much suggests being infinite. I'm not sure though how much thought whoever wrote that bible passage really put into it. 🤨