Is there a way we can remove the replace button in document library? Maybe using event receiver? I want the users not be able to replace the file with the same name
This may be too simple, but what about using permission levels to disallow users from being able to modify documents?
We routinely create and use custom permission levels whenever we need to control users' ability to upload content into a list/library but do not want to grant them Edit/Contribute access.
For instance, you could open the Edit permission level, and hit the Copy button to create a new permission level starting from the same permissions as Edit. Then name it something like "Create Not Edit Not Delete" and uncheck all of the edit and delete permissions. Then delegate the new permission level to your user/group in the site/library, and they'll only be able to add files.
Since they don't have delete or modify access, they won't be able to rename or upload & overwrite files.
It's not exactly what you want, but might work if it fits your usage scenario. Good luck!
Based on my research, we cannot remove or hide "Replace" button in Document library from SharePoint Online, it is by design.
Here is a similar case for your reference: