Exception on rendering html empty pipeline

### Describe the bug

Rendering empty pipeline to html fails, and just simply displaying an empty pipeline fails on IPython/Jupyter.

See upstream IPython issue:

https://github.com/ipython/ipython/issues/14568

### Steps/Code to Reproduce

```python
>>> from sklearn.pipeline import Pipeline
>>> pipeline = Pipeline(steps=[])
>>> pipeline
Pipeline(steps=[])
>>> from sklearn.utils._estimator_html_repr import estimator_html_repr
>>> estimator_html_repr(pipeline)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/bussonniermatthias/miniconda3/envs/arm64/lib/python3.12/site-packages/sklearn/utils/_estimator_html_repr.py", line 348, in estimator_html_repr
    check_is_fitted(estimator)
  File "/Users/bussonniermatthias/miniconda3/envs/arm64/lib/python3.12/site-packages/sklearn/utils/validation.py", line 1660, in check_is_fitted
    if not _is_fitted(estimator, attributes, all_or_any):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bussonniermatthias/miniconda3/envs/arm64/lib/python3.12/site-packages/sklearn/utils/validation.py", line 1579, in _is_fitted
    return estimator.__sklearn_is_fitted__()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bussonniermatthias/miniconda3/envs/arm64/lib/python3.12/site-packages/sklearn/pipeline.py", line 1096, in __sklearn_is_fitted__
    check_is_fitted(self.steps[-1][1])
                    ~~~~~~~~~~^^^^
IndexError: list index out of range
```

or just in IPython:

```python
# This code fails - EMPTY pipeline is rendered

from sklearn.pipeline import Pipeline

# Create pipeline
pipeline = Pipeline(steps=[])
pipeline
# same error, no need to explicitely call the repr code as it is registerd.
```

### Expected Results

Don't raise in the repr_handler.


### Actual Results

```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/bussonniermatthias/miniconda3/envs/arm64/lib/python3.12/site-packages/sklearn/utils/_estimator_html_repr.py", line 348, in estimator_html_repr
    check_is_fitted(estimator)
  File "/Users/bussonniermatthias/miniconda3/envs/arm64/lib/python3.12/site-packages/sklearn/utils/validation.py", line 1660, in check_is_fitted
    if not _is_fitted(estimator, attributes, all_or_any):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bussonniermatthias/miniconda3/envs/arm64/lib/python3.12/site-packages/sklearn/utils/validation.py", line 1579, in _is_fitted
    return estimator.__sklearn_is_fitted__()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bussonniermatthias/miniconda3/envs/arm64/lib/python3.12/site-packages/sklearn/pipeline.py", line 1096, in __sklearn_is_fitted__
    check_is_fitted(self.steps[-1][1])
                    ~~~~~~~~~~^^^^
IndexError: list index out of range
```

### Versions

```shell
sklearn: 1.5.2
```

COMMENT:
I don't think `__repr__` should ever raise. I'm more in favor of returning something representing an empty pipeline, and fixing the rendering as well.

@gdacciaro thanks for the quick PR. I think you can update your PR accordingly, and once finished, ping me for a review.

Note that you also need to add tests for whatever new code your write, and add a change log entry.

Labels: Bug