I found an answer by myself, and it is YES.
For those who may need it.
Install a tool that can create a compile_commands.json from a makefile like compiledb or bear (in the following I will use compiledb)
1) Go on Project-> Properties and change add the folder where compiledb is installed in PATH as shown below.

2) Go to Project -> Build Targets -> Create... Uncheck all the options and add the custom command you need for creating the compile_commands.json file in the Build commands.

3) Select the newly created target on the left hand side of CubeIDE, right click and select Build Target.

4) Once your compile_commands.json is created, you have to move it in the upper folder (root of your project).
You may have some error related to cyclomatic-complexity, but to solve this is enough to open the compile_commands.json file and remove all the -fcyclomatic-complexity entries.
OBS! I have just discovered this method, so take it with a grain of salt.