In OnlineGDB, I'm afraid, you cannot rename the file marked "main.cpp". However, you can create a new file right above the "main.cpp" tab, and you can copy-paste your content of your "main.cpp" to that new file.
For any file other than "main.cpp", you will find an ellipsis (...) after the name of the file, which offers the rename option.
I hope this is what you were after.