Cut the pumpkin or squash into thin wedges about 1 cm (½ inch) thick, discarding the seeds and fibres, and put in a large dish.
Heat a heavy-based frying pan until hot, add the whole spices and cook over a medium heat, stirring, until browned. Leave to cool, then grind to a powder in a spice grinder or in a mortar with a pestle. Mix the ground spices with the oil and sugar or mango chutney in a small bowl, then add to the pumpkin wedges and toss well to coat.
Cook the pumpkin or squash wedges under a preheated hot grill, or over a preheated hot gas barbecue or the hot coals of a charcoal barbecue, for 6–8 minutes on each side until charred and tender.
Meanwhile, make the pesto. Put the coriander leaves, garlic, chilli, sugar and pistachio nuts in a food processor and process until fairly finely ground and blended. Season with salt and pepper. Add the coconut cream and lime juice and process again. Transfer to a serving bowl.
Serve the wedges hot with the coconut pesto.