Sleep
If this is a Windows PC and you can write a WIN32 C++ program then you can look at the WH_KEYBOARD_LL()
function and use that to inject the "sleep key", but I'm not sure the "sleep key" isn't an OEM key which might make things difficult.
You could also look at sending a remote command (shutdown) over the network, but you'd have some hefty protocols to implement. Unless you had a service on your PC that listened to the serial connection and waited for the device to send a sleep command to it over that and converted it into a system call. The same will work with a Linux Daemon.
Wake Up
You can get Windows (don't know about Linux) to let a USB device wake it up, but I don't know if you could get a Arduino/ESP to send the correct signals.
Like The great Majenko says WoLAN is an option, but difficult to achieve.
My preferred option would be to splice a wire into the power button of the PC in parallel (so you can still use the button) and control that with a relay. That should give you a Wifi enabled power switch, but you need to check how the switch works and mimic it properly. I would try it with an old, almost dead, worthless PC first if I was you.