I think the issue you may be having may be with linux permissions, more a linux issue than PHP?
PHP runs under a separate user account to you. (try the whoami command) On my system, the username is apache instead of my normal user account for the PHP and apache programs. Try this:
<?php
var_dump( shell_exec( 'whoami' ) );
I used var_dump instead of echo so we can see any non-scalar data types that may be returned where required (See here).
Now... What your issue most likely is, is that when running a process list from a non-root account, it will only give you the list of processes associated with your account. I ran across this issue when I was creating a system monitoring application for work. If you do a process list from root or if you use sudo, you should theoretically get every process.
The solution, however, is NOT to sudo your webserver account - this would be a major security flaw. The solution is to find another way to do what you want to do. For me, I was able to create a bash script triggered every minute by a cron job that would grab all the information I required and save it in JSON format to a file accessible by the web server.
What, exactly, is it that you are trying to achieve?
EDIT:
I've noticed in response to another answer that you are getting results when invoking the script from PHP in terminal. This is because you will be running PHP with the same permissions as your user account, meaning PHP is running the pgrep command as your user account. You should see exactly the same results from PHP that you would from manually running it.