To set both the window and the taskbar icon, you need to first use the ctypes commands and Afterwards the root.iconbitmap command. The skript should look something like this:
import tkinter as tk
import ctypes
# sets a basic window
root = tk.Tk()
root.title("Window")
root.geometry("800x600")
# this is the part that sets the icon
myappid = 'tkinter.python.test'
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
root.iconbitmap(r"icon_path") # used raw string to avoid backslash issues
root.mainloop()
Reference: https://www.youtube.com/watch?v=pHpI8g0COZw