Part 1: Set Default UTF-8 encoding for New Notepad Documents When Saving File for Legacy Windows (Less than Version 1903)
# Create a file in UTF-8 encoding by using the New-Item command
# New-Item -Name TXTUTF-8.txt -ItemType File # Doesn't work on Windows 2016
# Borrowing the dot-net method https:// docs.microsoft.com/en-us/dotnet/api/system.text.utf8encoding?redirectedfrom=MSDN&view=net-5.0
$utf8Encoding = New-Object System.Text.UTF8Encoding $True
[System.IO.File]::WriteAllLines("$([System.IO.Path]::GetTempPath())TXTUTF-8.txt",'',$utf8Encoding)
Move-Item "$([System.IO.Path]::GetTempPath())TXTUTF-8.txt" "$ENV:WINDIR\SHELLNEW" -Force

# Creating registry key
$registryShellNew='REGISTRY::HKEY_CLASSES_ROOT\.txt\ShellNew'
$registryFileName='FileName'
$registryFileNameValue='TXTUTF-8.txt'
Set-ItemProperty -Path $registryShellNew -Name $registryFileName -Value $registryFileNameValue

# Reverse the change
Remove-ItemProperty -Path $registryShellNew -Name $registryFileName
Remove-Item "$ENV:WINDIR\SHELLNEW\TXTUTF-8.txt" -Force
Part 2: Set Notepad Default encoding UTF8 for Windows 10 (Version 1903 or Newer)
# Setting default encoding
$registryNotepad='REGISTRY::HKEY_CURRENT_USER\Software\Microsoft\Notepad'
$registryNotepadDefaultEncoding='iDefaultEncoding'
$registryNotepadDefaultEncodingValue=5
Set-ItemProperty -Path $registryNotepad -Name $registryNotepadDefaultEncoding -Value $registryNotepadDefaultEncodingValue

gi 'REGISTRY::HKEY_CURRENT_USER\Software\Microsoft\Notepad'

# The PoSH commands above recreates this registry value:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Notepad]
"iDefaultEncoding"=dword:00000001

; 1 = ANSI
; 2 = UTF-16 LE
; 3 = UTF-16 BE
; 4 = UTF-8 BOM
; 5 = UTF-8

# Reverse the change
Remove-ItemProperty -Path $registryNotepad -Name $registryNotepadDefaultEncoding