It is not uncommon to encounter a black screen on a Mac while installing macOS. The possible causes could be software or firmware issues, hardware issues, power issues, poor contact, etc. If the standard recovery mode is not working, you can try the Internet recovery mode.
It is necessary to reformat a used Mac to clean all the content and reinstall macOS. When you see the Mac black screen, you can first reboot the Mac into macOS Recovery Mode to try to reinstall macOS there. If the problem remains, try to access Disk Utility to run First Aid to check and repair the drive, the formatted one.
If there are no found errors with First Aid and you can't bypass the black screen to install macOS, the local recovery partition may be corrupted, so try Internet Recovery Mode, an Internet-based version of Recovery Mode that loads recovery utilities from Apple's servers over the Internet.
You can boot an Intel Mac into Internet Recovery Mode by restarting the Mac and simultaneously holding Command + Option + R or Command + Shift + Option + R. For an Apple silicon Mac, the Internet Recovery Mode is combined with the standard recovery mode, there is no difference, and the Internet connection is required.