Here is how you could write it (you may want to test this code, however).
Something to note about using DB::raw:
DB::raw() is used to make arbitrary SQL commands which aren't parsed any further by the query builder. They therefore can create a vector for attack via SQL injection.
With that in mind, I am using them here assuming that you aren't passing any user input into them in order to do the counting and conditional query parameters.
Please, take a look at the Laravel Documentation for more info on how the query builder works. Most people won't always be kind enough to write your queries for you.
// compile the sql for the select query
$selectRaw = \DB::table('log')->select([
'username',
'status_id',
'status_desc',
\DB::raw('count(status_desc) as count')
])->groupBy('username', 'status_id', 'status_desc')->toSql();
// create and execute the full query
$result = \DB::table(\DB::raw("({$selectRaw}) as t"))->select([
't.username',
\DB::raw('sum(case when t.status_id = 1 then t.count else 0 end) as status_1'),
\DB::raw('sum(case when t.status_id = 0 then t.count else 0 end) as status_0'),
\DB::raw('sum(case when t.status_id = 0 and t.status_desc = 2 then t.count else 0 end) as status_0_2'),
\DB::raw('sum(case when t.status_id = 0 and t.status_desc = 3 then t.count else 0 end) as status_0_3'),
])->groupBy('t.username')->get();