Here’s a solution that works with both headless and non-headless mode and will start the window with the specified size instead of setting it after:
Chrome:
from selenium.webdriver import Chrome, ChromeOptions
opts = ChromeOptions()
opts.add_argument("--window-size=2560,1440")
driver = Chrome(options=opts)
Firefox:
from selenium.webdriver import Firefox, FirefoxOptions
opts = FirefoxOptions()
opts.add_argument("--width=2560")
opts.add_argument("--height=1440")
driver = Firefox(options=opts)