I managed to get it working even when the app wasn't active or had any windows open using the code below. On Apple's Developer Documentation Apple's Developer Documentation it is stated that it will request a window to become active, even if non are present. You might want to combine this with an if statement to check whether or not a person is using MacOS Sonoma or an older version like MacOS Ventura.
Settings {
ContentView()
}
MenuBarExtra("Test", systemImage: "circle.fill"){
SettingsLink{
Text("Settings")
}.keyboardShortcut(",", modifiers: .command)
}
I had the same problem as you, but I came up with this code which worked.