Pastor Keller contributed the following to the comments section of this post.
The Greek word for ‘religion’ used in James 1 is used negatively in Colossians 2:18 where it describes false asceticism, fleshly works-righteousness, and also in Acts 26:5 where Paul speaks of his pre-Christian life in strict ‘religion’. It is also used negatively in the Apocrypha to describe idol worship in Wis 14:18 and 27. So the word certainly has enough negative connotations to use as a title for the category of works-righteousness. In the Old Testament the prophets are devastating in their criticism of empty ritual and religious observances designed to bribe and appease God rather then serving, trusting, and loving him. The word ‘religion’ isn’t used for this approach, but it’s a good way to describe what the prophets are condemning.