ameenpv I don't think we have any existing extension for that.
It shouldn't be difficult to implement.
I'd guess the reason no one made this yet is probably because it's a very non-friendly way of prompting users. Something like the "See past first post" or "Reply to see" might be more engaging for guests.
Depending on your use case, maybe the "Direct links" extension could be useful, if you want to put a link in a menu which will direct to the forum and open the login modal automatically.