Out of the box there's no functionality that does this. However, you have several options regarding locations:
1. If these location codes don't have any inventory, you can delete the location card. The historical information will still remain in all the ledgers and display the corresponding location code, its just the location card itself that is deleted.
2. You can use security filters in permission sets to hide these inactive locations.
3. You can rename these locations to add a Z, ZZ, or ZZZ at the beginning of the location code, this way you know they're inactive and will sit at the bottom of the location list.
4. You can create a customization that adds a blocked field to the location card. Then you can add a filter to the location dropdown to not show any blocked locations.
Regarding customers, there is also no out of the box solution as well. You can block them on the customer card and then either hide them using customization, however, you will need to customize quite a few areas of the system. Or, similarly to locations, you can rename them to add a Z at the beginning of the name, or use security filters to hide them.