Macbook Pro function buttons not working following changed battery
I would start with the following:


Go to Apple > System Preferences
Select the Keyboard preferences pane
Ensure you have the Keyboard tab selected
Double-check your settings and change if necessary


Let me know how you go.



[EDIT 1]

Okay, now that we know your settings are fine, let's see whether booting into Safe Mode makes a difference, either during or afterwards.

Boot into Safe Mode

Follow these steps to boot your Mac into Safe Mode:


Fully shut down your Mac
Restart your Mac
Immediately press the Shift key and keep it down 
Let go of the Shift key when you see the login window (NOTE: If you have FileVault enabled you may need to log in twice).
Take a note of what happens (i.e. what happens when you press the function keys, etc)
Exit Safe Mode by restart your Mac as normal
Again, take a note of what happens (i.e. what happens when you press the function keys, etc)


Let me know how you went and we'll go from there.



[EDIT 2]

Let's test your hardware. We can do this by running Apple Diagnostics.

Run Apple Diagnostics

Follow the steps below to run Apple Diagnostics:


Fully shut down your Mac
Restart your Mac
Immediately press the D key and keep it down until you see the Diagnostics screen appear
Wait for Diagnostics to finish (this typically only takes a few minutes)
Once complete, one of two things will appear on the screen:


a No issues found message
a brief description of any errors found plus further instructions

If the diagnostics test does find errors, take a note of what they are


Note: If pressing and holding the D key at Step 3 doesn't work, start again at Step 1 and, at Step 3 press and hold both the OptionD keys instead. This will try and run diagnostics from the internet instead, so you will need to allow more time for it to complete. 

Regardless, take a note of what happens and let me know how you went.

[EDIT 3]

Ok, here are a couple more tests you can try to isolate things further:


Try connecting an external keyboard (any cheap USB keyboard will do) and testing the Function key behaviour on that.
Try booting up from another drive (if you can) and test things.


Let me know the results of either or both tests.