There are no way to user GroupBy in pnp js, because it not exists.
But, you can grouping data after you get it in javascript.
For example, you have some interface to store result data, somthing like this:
interface IData{
Id: number;
Title: string;
}
interface IGroups{
Title: string;
Ids: number[];
}
And after you get request response, you create array of objects
let result: IData[] = [];
query.then((items)=>{
items.map((item)=>{
result.push({Id: item.ID, Title: item.Title});
});
});
After this you get not grouped data, which you can group by filtering:
let groups: IGroups[] = [];
result.map((item)=>{
//get only titles for grouping
return item.title;
}).filter((value, index, self)=>{
//get unique values
return self.indexOf(value)===index
}).map((item)=>{
//Here you get distinct title - you groups
//and creating groups
groups.push({
Title: item,
Ids: result.filter((r)=>{return r.title === item})
});
});