Sharepoint - How to disable "Connect to Teams" banner in SharePoint Online

You need to use /_api/groupsitemanager/HideTeamifyPrompt method to disable the Teamify banner.

You can use it in PnP PowerShell as below:

Connect-PnPOnline -Url ""

$jsonBody = "{'siteUrl':''}"

Invoke-PnPSPRestMethod -Method Post -Url "/_api/groupsitemanager/HideTeamifyPrompt" 
-Content $jsonBody -ContentType "application/json;odata=nometadata"

Reference - What's new in SPO REST API's

Ensure that you are using the latest PnP PowerShell module or atleast the one after May 2019 release ( v3.9 or higher)

This can be done via PowerShell:

$tenant = ""
$web = ""

Connect-PnPOnline -Url $tenant -SPOManagementShell
$site = Get-PnPTenantSite -Detailed -Url $web
if ($site.DenyAddAndCustomizePages -ne 'Disabled') {
    $site.DenyAddAndCustomizePages = 'Disabled'

Set-PnPPropertyBagValue -Key 'TeamifyHidden' -Value 'True'