On the basis of the link published by kohske, I have finally managed to find a workaround, i.e. to define the figure number according to a template
Figure #section.#figure
For example: Figure 3.1
This is not what I initially wanted to do (i.e. remove the automatic numbering of figures), but it is a nice workaround.
How to do it
First of all, create a 'mystyle.sty' file located in the same directory as your rmarkdown file. Within this mystyle.sty file, put the following line of code:
\usepackage{chngcntr}
Then, in the header of your rmarkdown file, add the following information:
output:
pdf_document:
fig_caption: yes
includes:
in_header: mystyle.sty
The purpose of this was to make sure that rmarkdown asks latex to use a package allowing you to create an appropriate automatic numbering.
The next step is to add this at the beginning of the document:
\counterwithin{figure}{section}
so the figures will be numbered in each section.
And then, you can manually define the value of "section" and "figure" with \setcounter{section}{#}
Actually, what you have to do is simply to put the two following lines at the beginning of each section:
\setcounter{section}{1}
\setcounter{figure}{0}
If you are in section 3, change \setcounter{section}{1}
to \setcounter{section}{3}
.
And this works properly; for example the figure 3 of my section 5 is:

However, there is still another issue left: although this solves the knit PDF problem, this will not work for HTML. If you use the same document to generate PDF and HTML files, then your PDF will have good numbers, and your HTML won't have any number. I still haven't figured out how to do the same thing in HTML.