Sprint Goal is a sacred thing in scrum - it's the main priority of the sprint, and all developers shuold work together towards achieving it. Failing to achieve it is bad, and shouldn't be allowed to happen.
What should happen however when that is assured and there is still spare dev power in the team? That is a possibly common occurrence (given you would err on the side of achieving Sprint Goal while planning), and I couldn't find anything in scrum guide detailing what to do.
- You could add a new task they pick up to the sprint - but that is scope change, one that carries a serious risk of becoming a spillover
- You could let the developer just pick up a story that's not part of sprint - but than how do you track the work, that story does not show up on the sprint board, has no bounds on when it should be achieved and generally seems to be outside the system
- you could only let devs pick stories that can be finished in the sprint goal - at the risk that last one-two days of the sprint there will be no such stories.