You can use BreakRoleInheritance method of ListItemAllFields property.
In my code snippet "Test Library" is the document library title and "Test Folder" the name of the target subfolder.
using (var scope = host.Services.CreateScope())
{
// Ask an IPnPContextFactory from the host
var pnpContextFactory = scope.ServiceProvider.GetRequiredService<IPnPContextFactory>();
// Create a PnPContext
using (var context = await pnpContextFactory.CreateAsync(new Uri(siteUrl)))
{
// Get Root Folder
var rootFolder = (await context.Web.Lists.GetByTitleAsync("Test Library", p => p.RootFolder)).RootFolder;
// Ensure SubFolder
var subFolder = await rootFolder.EnsureFolderAsync("TestFolder");
// Break Inheritance on SubFolder [BreakRoleInheritance(bool copyRoleAssignments, bool clearSubscopes)]
subFolder.ListItemAllFields.BreakRoleInheritance(false, true);
// Get current user
var currentUser = await context.Web.GetCurrentUserAsync();
// Find role definition
var roleDefinitions = (await context.Web.GetAsync(p => p.RoleDefinitions)).RoleDefinitions;
var editRole = roleDefinitions.AsRequested().FirstOrDefault(p => p.Name == "Edit");
// Add role to selected user
await subFolder.ListItemAllFields.AddRoleDefinitionAsync(currentUser.Id, editRole);
}
}